Front End Technology Articles - Page 471 of 652

Searching an element in Javascript Array

Sharon Christine
Updated on 15-Jun-2020 08:05:09

599 Views

Javascript provides a collection of functions that you can use to find elements in an array. Let's start with the most basic one. The indexOf function goes through the entire array and returns the index of the element you searched for, if it is found else it returns -1. For example, Examplelet people = ["Harry", "Martha", "John", "Sam"]; console.log(people.indexOf("John")) console.log(people.indexOf("Jim"))OutputThis will give the output −2 -1There are other, more complex functions that you can use to make search more powerful. Let's look at find() method. The find() method returns the first object matching the condition you provide it as the ... Read More

Joining two Arrays in Javascript

Sharon Christine
Updated on 15-Jun-2020 08:12:22

316 Views

There are two ways to join 2 arrays in Javascript. If you want to get a new array and not want to disturb the existing arrays while joining the two arrays then you should use the concat method as follows − Examplelet arr1 = [1, 2, 3, 4]; let arr2 = [5, 6, 7, 8]; let arr3 = arr1.concat(arr2); console.log(arr1); console.log(arr2); console.log(arr3);OutputThis will give the output −[1, 2, 3, 4] [5, 6, 7, 8] [1, 2, 3, 4, 5, 6, 7, 8]Note that the existing arrays were not modified. If you want to join in place, you'll need to use the ... Read More

Removing an element from a given position of the array in Javascript

Sai Teja Kotha
Updated on 07-Dec-2022 13:12:21

355 Views

In this article, we are going to discuss removing an element from a given position of the array in JavaScript. The delete operator, the slice() method, and the splice() method can be used to remove an element from a given position of the array in this article. Following is the syntax of the delete operator. let del = delete arr[index]; Following is the syntax of the slice() method. arr.slice(start, end) Following is the syntax of the splice() method. arr.splice(position, no_of_elem) Using delete Operator Example In this example, we are going to discuss the use of the ... Read More

Removing an element from the start of the array in javascript

Sai Teja Kotha
Updated on 07-Dec-2022 13:06:54

199 Views

In this article, we are going to discuss removing an element from the start of the array in JavaScript. For that, we are going to use the _.rest() method. This method returns the array elements except for the 0th indexed element. We can also use the shift() method and the slice() method to remove the first element from an array. Let us see the implementation of it further. Using _.rest() Method The following example demonstrates how to remove the start element from an array in JavaScript. Syntax The syntax of the _.rest() method is − _.rest( array, index ); ... Read More

Adding an element at the start of the array in Javascript

Lokesh Badavath
Updated on 21-Nov-2022 11:09:37

420 Views

In this article, we are going to learn how to add an element at the start of the array in JavaScript. An array is a special variable, which can hold more than one value sequentially. It is a collection of items stored at contiguous memory locations. The idea is to store multiple items together. This makes it easier to calculate the position of each element by simply adding an offset to a base value of the memory location of the first element of the array. The base value is index 0 for the first element in the array and the ... Read More

Adding an element at the end of the array in Javascript

Lokesh Badavath
Updated on 21-Nov-2022 12:05:32

575 Views

In this article, we are going to add an at the end of the array in JavaScript. An array is a special variable, which can hold more than one value. An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items together. This makes it easier to calculate the position of each element by simply adding an offset to a base value of the memory location of the first element of the array. The base value is index 0 for the first element in the array and the difference between the two ... Read More

Arrays Data Structure in Javascript

Samual Sam
Updated on 15-Jun-2020 07:32:42

571 Views

The array is a container which can hold a fixed number of items and these items should be of the same type. It stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.Why do we need arrays?Let's say you want to record the average temperatures of all days of the week. You can record them as follows −let avgTempMon = 35; let avgTempTue = 33; let avgTempWed = 31; ... Read More

Set a container that spans the full width of the screen with Bootstrap

Lakshmi Srinivas
Updated on 12-Jun-2020 21:16:41

2K+ Views

Use the .container-fluid class in Bootstrap to set a container that spans the full width of the screen.You can try to run the following code to implement the container-fluid classExampleLive Demo           Bootstrap Example                                          Container fluid          Normal width          Width is 75%          Width is 50%          Width is 25%          

Create a button look like a link with Bootstrap

Lakshmi Srinivas
Updated on 12-Jun-2020 20:51:27

5K+ Views

Use the .btn-link class in Bootstrap to create a button look like a link.You can try to run the following code to implement a .btn-link classExampleLive Demo           Bootstrap Example                                 The following are FMCG companies:                ITC Limited          Colgate-Palmolive          Nestle          Britannia Industries Limited          

Make a group of buttons span the entire width of the screen with Bootstrap

Rishi Rathor
Updated on 12-Jun-2020 20:27:18

927 Views

To make a group of buttons span entire width of the screen, use the .btn-group-justified.You can try to run the following code to implement the .btn-group-justified class −ExampleLive Demo           Bootstrap Example                                 The following are the car brands:                BMW          Audi          Jeep          Datsun          Toyota             The following are FMCG:                ITC Limited          Colgate-Palmolive          Nestle          Britannia Industries Limited          

Advertisements