In the following code xFoo will be an object that (or its prototype) has an actual property bar with a value of 5 and it will will have an actual method foo(). What kind of object notation is this? This is not how I define properties in ECMAScript 5. I would have expected that xFoo.bar is an object that has a function get() and that xFoo.foo is an object that has a method value(). What am I missing here?
var XFoo = document.registerElement('x-foo', {
prototype: Object.create(HTMLElement.prototype, {
bar: {
get: function () {
return 5;
}
},
foo: {
value: function () {
alert('foo() called');
}
}
})
});
var xFoo = new XFoo();