Last active
May 30, 2020 17:48
-
-
Save sashasushko/fbba2c2185d0ed09ddba8319274ecb78 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
var increaseByTwo = function (value) { | |
/* увеличиваем свойство переданного объекта на 2 */ | |
value.number += 2; | |
/* возвращаем результат */ | |
return value; | |
}; | |
/* объявляем переменную со сложным значением - объектом */ | |
var obj = { | |
number: 2 | |
}; | |
console.log(obj); | |
/* получим { number: 2 } */ | |
console.log(increaseByTwo(obj)); | |
/* функция выполнится и вернёт { number: 4 } */ | |
console.log(obj); | |
/* получим также { number: 4 }. Исходный объект изменился! */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment