1

I am new to JS and I wonder why this piece of code prints false. What am I doing wrong? Thank you for any hint!

var x = Object.create(Object.prototype, {x:{value:3, writable:true, enumerable:true}});

console.log(x.propertyIsEnumerable(x)); //false

1 Answers1

1

Well, you missed the quotes:

x.propertyIsEnumerable('x')

See below:

var x = Object.create(Object.prototype, {x:{value:3, writable:true, enumerable:true}});

console.log(x.propertyIsEnumerable('x'));
kukkuz
  • 41,512
  • 6
  • 59
  • 95