nas5w / javascript-tips-and-tidbits

A continuously-evolving compendium of javascript tips based on common areas of confusion or misunderstanding.
MIT License
1.2k stars 73 forks source link

Value vs Reference small error #1

Closed D8ATech closed 5 years ago

D8ATech commented 5 years ago

In the first section the proposed output is not correct

let var1 = 'My string'; let var2 = var1;

var2 = 'My string';

console.log(var1); // 'My string' console.log(var2); // 'My new string'

For console.log(var2); to output My new string line 4 needs to be var2 = 'My new string'

nas5w commented 5 years ago

Whoops, you’re saving my bacon on this one. Right at the beginning too! Feel free to do a pull request to fix or I’ll be able to do it in a bit. Thanks Craig!