I wouldn't expect toLocaleString to be part of the Object.prototype since there's no local in Espruino, but I found it weird propertyIsEnumerable and isPrototypeOf are not implemented.
A quick and dirty solution would be the following:
Object.prototype.propertyIsEnumerable=function(p){for(var k in this)if(k==p)return this.hasOwnProperty(k);return false};
Object.prototype.isPrototypeOf=function(o){return o instanceof this.constructor};
However, instanceof is also broken in Espruino. Above code uses the constructor but a proper check would be the equivalent of the following:
Object.prototype.isPrototypeOf=function(o){
function F() {}
F.prototype = this;
return o instanceof F;
};
// this should be true
Object.prototype.isPrototypeOf({});
Latter check is false but it should be true. Ideally, isPrototypeOf and propertyIsEnumerable should be implemented natively.
Last question for now, I'v enoticed that RegExp and in general regular expression /syntax/ is not implemented. Is that too big to bring in natively or it's something planned already?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I wouldn't expect
toLocaleString
to be part of theObject.prototype
since there's no local in Espruino, but I found it weirdpropertyIsEnumerable
andisPrototypeOf
are not implemented.A quick and dirty solution would be the following:
However,
instanceof
is also broken in Espruino. Above code uses theconstructor
but a proper check would be the equivalent of the following:Latter check is false but it should be true. Ideally,
isPrototypeOf
andpropertyIsEnumerable
should be implemented natively.Last question for now, I'v enoticed that
RegExp
and in general regular expression /syntax/ is not implemented. Is that too big to bring in natively or it's something planned already?Thanks