I was using array like this
var names=['a','b','c'];
when I tried to access names[5]. it returns undefined simply,gives no error.
After that I changed my array like this
var names=[];
for(var i=0;i<inputNumberByUser;i++) //guys my array is populating dynamically,depends upon user input
{
names.push({FirstName:'abc',LastName:'zyx'});
}
When I tried below code, it gives me error that, Could not read FirstName of undefined
names[5].FirstName;
why above line is giving error? it should just return undefined as normal array
names[5] and names[5].FirstName both are not defined. names[5] returns 'undefined' but names[5].FirstName error. thats my point. names[5].FirstName should also simply return 'undefined' as names[5] did