Last active
April 18, 2017 20:27
-
-
Save SergeyLipko/42369260f5e9ca63c4bd505bc29c0d18 to your computer and use it in GitHub Desktop.
Передача объектов по ссылке
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// в переменную "a" копируется ссылка на объект "b" | |
var a = b = { | |
value: 1, | |
}; | |
var b = { | |
value: 2, | |
}; | |
// следовательно когда изменяются какие-то поля объекта в переменной "a" | |
// на "b" это никак не отражается и наоборот | |
a.value = 3; | |
console.log(a.value); // 3 | |
console.log(b.value); // 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment