Advertisement
dhshin

call by value

Jun 26th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function increment_1(a){  
  2.   a = 100;
  3. }
  4.  
  5. function increment_2(a){
  6.   a = 100;
  7.   return a;
  8. }
  9.  
  10. let c = 3;
  11. console.log(increment_1(c)); // undefined
  12. console.log(c); // 3
  13. console.log(increment_2(c)); // 100
  14.  
  15. function append(array, value){
  16.   array.push(value)
  17. }
  18.  
  19. let array = [1, 2];
  20. append(array, 3);
  21.  
  22. console.log(array); // [1, 2, 3]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement