-4

property myProperty is not assigned to variable foo, foo is an object.

var foo=null;//null is an object
foo.myProperty = "my value";
console.log(typeof foo.myProperty);
ANILGAGAN
  • 5
  • 4

1 Answers1

1

A Javascript object should be declared like this

var myObject = {};

Try to modify you code like

var foo = {};
foo.myProperty = "a string";
console.log(typeof foo.myProperty);
michele
  • 169
  • 4