Fun fact: in javascript, if you write { __proto__: someObject }, it will set the...
kimapr β πΊπΏ β§ β’ β€οΈπ§‘π€π©·π @kimapr@ublog.kimapr.net
Fun fact: in javascript, if you write { __proto__: someObject }, it will set the prototype of your new object to someObject instead of creating a __proto__ property on your object
this also works if you put it in quotes: { "__proto__": someObject }, which is different from the Jason semantics:
for (let [k,v] of [
['Jason', JSON.parse],
['JavaS', e=>eval(e)]
]) {
console.log(k+':', v('[{"__proto__": null}]'))
}
// Jason: [ { ['__proto__']: null } ]
// JavaS: [ [Object: null prototype] {} ]
however, despite using the same special name, none of the following set the prototype on the object literal, and instead create a property named __proto__:
{ ["__proto__"]: someObject }
//let __proto__ = someObject
{ __proto__ }
{ __proto__() { /*code...*/ } }