Created
September 13, 2019 07:21
-
-
Save novonimo/58a3b01f1a5d25e89de1f59074ee5d3f 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
/* | |
increase function will use number but it copy new number for use it | |
number is a Primitive type so ther are independent and will not change | |
*/ | |
let number = 10; | |
function increase (param) { | |
param++; | |
console.log("param value is: ", param); | |
}; | |
increase(number); | |
console.log("number value (Primitive type): ", number); | |
/* | |
but here object (reference type) will behave differnetly | |
*/ | |
let object = {value: 10}; | |
function increaseObject (param) { | |
param.value++ | |
console.log("param value is: ", param); | |
} | |
increaseObject(object); | |
console.log("object value (Reference type): ", object) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment