Array

by Mahadevan Sivasubramanian

JavaScript

// initialize array data
var names = ['maha','deva','siva'];
var year = new Array(1990,1982,1948);

//mutate array data
names[1] = 'ramana';

console.log(names[0]);
// to display all array value
console.log(names);

// to find the length of array
console.log(names.length)

// Data types

var maha = ['Mahadevan', 'Sivasubramanian', 1982, 'STL', true]

// will add the value in the end of array
maha.push('blue');

// will add the value in the beginning of array
maha.unshift('Mr.')

// will remove the value in the end of array
maha.pop();

// will remove the value in the beginning of array

maha.shift();

console.log(maha);

// Indexof will show the position of the array value

console.log(maha.indexOf(1982));