nas5w/javascript-tips-and-tidbits

Value vs Reference small error

D8ATech opened this issue · 1 comments

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

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!