var b = true;
b.foo = 'whatever'; // Auto-boxing occurs?
b.foo; // undefined - why?
Can I retrieve the value of property foo now?
var b = true;
b.foo = 'whatever'; // Auto-boxing occurs?
b.foo; // undefined - why?
Can I retrieve the value of property foo now?
var b is initially set to Boolean value. to assign dot notation to a variable, it has to be a javascript Object.
if b is set as var b = {}, b.foo = 'whatever'; should work.
For better practice always check type of variable before switching its datatype:
var b = true;
if(typeof b === 'object'){
b.foo = 'whatever';
}