// 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));
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.