Saturday, December 22, 2018

html - Is JavaScript pass-by-reference or pass-by-value?




Is JavaScript language a pass-by-reference or pass-by-value language?




Also is it different for primitive types Vs for objects ?


Answer



Objects are passed by reference while primitives are passed by value.



Note, that primitive values include the following:




  • number

  • String

  • boolean


  • undefined

  • null



You can find some more details at MDN on Functions.


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...