Javascript Challenges

Undefined values in Array

See the next snippet of code:

var arr = [];
arr.length = 10;
// The next statement shows [] in the console.
console.log(arr);
// The next statement shows [undefined × 10] in the console.
arr;
// The next statement shows undefined in the console.
console.log(JSON.stringify(arr[0]));

Snippet 1

console.log(JSON.stringify(arr));

Exercise

Correct!
False!

What will be shown in the console if we execute Snippet 1?

Exercise

Correct!
False!

Why?

Snippet 2

console.log(arr.toString());

Exercise

Correct!
False!

What will be shown in the console if we execute Snippet 2?

Exercise

Correct!
False!

Why?