What will be the value of x [0] and x===y after the following code is executed?

var x = [];
var y = x;
y[0] = 7;
console.log(x[0]);
console.log(x===y);
Explanation
In JavaScript objects have a reference type. var y = x; will assign the link to an object (array) and will not create a new copy of object.

+Володимир Оніщенко, fixed

2015 Jun 30, 6:31:00 PM

There is an error that 2 answer options are correct but you can choose only 1

2015 Jun 29, 5:45:06 PM

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты