38. Javascript Arrays - Full stack web development Course

preview_player
Показать описание
In this FullStackWebDevelopment tutorial series video, We will learn about #javascript #arrays and #methods .

An array is a special variable, which can hold more than one value at a time. An array can hold many values under a single name, and we can access the values by referring to an index number.

In JavaScript, array is a single variable that is used to store different elements. It is often used when we want to store a list of elements and access them by a single variable. Unlike most languages where array is a reference to the multiple variable, in JavaScript array is a single variable that stores multiple elements.

Syntax: var array_name = [item1, item2, ...];

We can access an array element by referring to the index number. Array indexes start with 0.[0] is the first element. [1] is the second element and so on.

- The push() method is used to add new items to the end of an array, and returns the new length. The new item(s) will be added at the end of the array. Also this method changes the length of the array. To add items at the beginning of an array, use the unshift() method.

- The indexOf() method Javascript array indexOf() is an inbuilt function that returns the first index at which the given item can be found in an array, or -1 if it is not present in an array. Javascript indexOf() method searches the array for a specified item and returns its position to the calling function.
If we want to search from end to start, use the lastIndexOf() method

----------------------------

Week 1 : Day 7
Section 5 : Learning to Code With Javascript
Tutorial 38: Javascript Arrays

----------------------------
Do subscribe and hit Bell Icon
----------------------------

Follow us in social media handles for opportunities and code related support.

----------------------------------------------------------

Got a question on the topic? Please share it in the comment section below and our experts will answer it for you.

Рекомендации по теме
Комментарии
Автор

i'm on the way.. to complete this series.. cause i need a internship

ritiksoni
Автор

**Edit, 5 seconds further into the video my question is answered... Keep It Simple Stupid!!
as an aside if anyone wants to know about splice i gotcha covered

can somebody please tell me exactly how I am messing up the splice function? I still get "Timmy" on console output been staring at this and researching both indexOf and splice for like an hour now

var students = ["Timmy", "Janessa", "Arin"];

var naughtyList = [];


var index = naughtyList.indexOf("Timmy");

if (index < -1) {
naughtyList = naughtyList.splice(index, 1);
}

console.log(naughtyList);

CYBRsynth