Upgrade to Pro — share decks privately, control downloads, hide ads and more …

javascriptの参照と値

 javascriptの参照と値

javascriptの参照渡しと値渡しについて

Transcript

  1. Pass by reference const A = {}; const B =

    A; B.x = 1; console.log(A); // { x: 1 }
  2. Pass by value const A = 1; const B =

    A; B++; console.log(A); // 1
  3. String behave like value let A = 'a'; let B

    = A; A += 'b' // Create new instance and assign to self. console.log(A); // 'ab'; console.log(B); // 'a;