potatoscript
Implementing javascript features that often confuse people.
potatoscript will implement js features as well as possible, in JS, with potatos
Because we can't use the identifiers used by javascript, we will use our own:
instead of proto we will use potato
and we will call this potatotypical inheritance.
new
new Constructor():
- creates a new, plain object. Assigns its
.__proto__toConstructor.prototype - applies the new object, and the arguments to the
Constructor - returns the result of the
applyIF it results in an Object, otherwise returns the new object.
Prototypical version:
Potatotypical version:
Tested via tests for the other potatotypical features.
prototypical get via key
object.foo:
- if
objecthas the key offoo, returns the value atobject.foo - If not, and
object.__proto__.__proto__exists, passesobject.__proto__to step 1. - If there are no more
__proto__s in the chain, returns undefined.
Potatotypical version:
instanceof
object instanceof Constructor:
- Returns true if
objecthas a.__proto__that isConstructor.prototype - If not, and
object.__proto__.__proto__exists, passesobject.__proto__to step 1. - If there are no more
__proto__s in the chain, returns false.