|
Answer» Array is a collection of index items and it is a number indexes.
Some of programming language support array as named indexes and the JavaScript not support the array as name indexes and its provide only number indexes but provide this feature using the ASSOCIATIVE array.
The array with name indexes are called associative array and the associative array is provide a ways to STORE the information.
The number index array example as given below
var USERS = new Object(); users["Name1"] = "Anil 1"; users["Name2"] = "Anil 2"; users["Age"] = 33; alert(Object.keys(users).length); //OUTPUT is 3. var length = Object.keys(users).length; // 3
The name index array example as given below var users = []; users["Name1"] = "Anil 1"; users["Name2"] = "Anil 2"; users["Age"] = 33; var length = users.length; // users.length will return 0 var detail = users[0]; // users[0] will return undefined Array is a collection of index items and it is a number indexes.
Some of programming language support array as named indexes and the JavaScript not support the array as name indexes and its provide only number indexes but provide this feature using the associative array. The array with name indexes are called associative array and the associative array is provide a ways to store the information. The number index array example as given below var users = new Object(); users["Name1"] = "Anil 1"; users["Name2"] = "Anil 2"; users["Age"] = 33; alert(Object.keys(users).length); //output is 3. var length = Object.keys(users).length; // 3 The name index array example as given below var users = []; users["Name1"] = "Anil 1"; users["Name2"] = "Anil 2"; users["Age"] = 33; var length = users.length; // users.length will return 0 var detail = users[0]; // users[0] will return undefined
|