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