I discovered this by accidentally leaving off the function
keyword. Ordinarily the foobar
method in the module below would be declared as foobar: function(arg1)
, but interestingly the following works, at least in some browsers, e.g. Chrome Version 44.0.2403.157 m, but it fails in IE 11.0.9600.17959
How is it possible that this runs at all in any browser? Is this some sort of new ES6 functionality?
var module = {
foobar(arg1) {
alert(arg1);
}
};
module.foobar("Hello World");
new o.preperty()
behaves normally. Using shorthand method names,new o.property()
throws an error. See here – Louden