Take a look at this code:
var arr = [];
arr[999] = 'john';
console.log(arr.length);
What is the result of execute "Snippet 1" code?
1000
__match_answer_and_solution__
var arr = [];
arr[4294967295] = 'james';
console.log(arr.length);
What is the result of execute "Snippet 2" code?
0
__match_answer_and_solution__
Why?
Because 4294967295 overflows the max number of elements that could be handled by Javascript in Arrays.
__match_answer_and_solution__
var arr = [];
arr[4294967295] = 'james';
console.log(arr[4294967295]);
What is the result of execute "Snippet 3" code?
"james"
__match_answer_and_solution__
Why?
Javascript arrays can work as objects, dictionaries, when you are using as key any value that can not be handled by Array objects.
__match_answer_and_solution__
var arr = [];
arr[Number.MIN_VALUE] = 'mary';
console.log(arr.length);
What is the result of execute "Snippet 4" code?
0
__match_answer_and_solution__
Why?
Javascript arrays can work as objects, dictionaries, when you are using as key any value that can not be handled by Array objects.
__match_answer_and_solution__
var arr = [];
arr[Number.MIN_VALUE] = 'mary';
console.log(arr[Number.MIN_VALUE]);
What is the result of execute "Snippet 5" code?
"mary"
__match_answer_and_solution__
Why?
Javascript arrays can work as objects, dictionaries, when you are using as key any value that can not be handled by Array objects.
__match_answer_and_solution__