ColdTree ColdTree - 11 months ago 48
Javascript Question

How to set a javascript var as undefined


console.log(boo); this outputs undefined


var boo = 1;
console.log(boo); this outputs 1

After defining boo and setting to 1, how can I then reset boo, so that console.log outputs undefined?


Answer Source

delete boo

Don't use var boo = undefined. undefined is just a variable and if someone sets undefined = "hello" then you'll be getting hello everywhere :)


null wasn't same as undefined. removed that bit.