array index javascript code example
Example 1: how to get element of an array in javascript
var value = [a,b,c,d];
var value_b = value[1];
Example 2: javascript array
var colors = ["red","blue","green"];
for (var i = 0; i < colors.length; i++) {
console.log(colors[i]);
}
Example 3: array javascript
var familly = [];
var familly = new Array()
var familly = [Talel, Wafa, Eline, True, 4];
console.log(familly[0])
familly[0] + "<3" + familly[1]
familly[3] = "Amir";
Example 4: array javascript
special_dates = [];
special_dates.push(new Date('2021/02/12').getTime());
special_dates.push(new Date('2021/02/13').getTime());
special_dates.push(new Date('2021/02/14').getTime());
for (var i = 0; i < special_dates.length; i++) {
console.log(special_dates[i]) ;
}
Example 5: javascript atualize array
let yourArray = [1,2,3,4,5];
yourArray[2] = 6
Example 6: access index of array javascript
let first = fruits[0]
let last = fruits[fruits.length - 1]