And JavaScript engines are highly optimized for this. Changing a prototype “on-the-fly” with Object.setPrototypeOf or obj.__proto__= is a very slow operation as it breaks internal optimizations for object property access operations.
Object.getPrototypeOf(obj) – returns the [[Prototype]] of obj. Object.setPrototypeOf(obj, proto) – sets the [[Prototype]] of obj to proto.
The only usage of __proto__, that’s not frowned upon, is as a property when creating a new object: { __proto__: ... }.
Object.create(proto[, descriptors]) – creates an empty object with given proto as [[Prototype]] and optional property descriptors.
The Object.create method is a bit more powerful, as it has an optional second argument: property descriptors.
Glasp is a social web highlighter that people can highlight and organize quotes and thoughts from the web, and access other like-minded people’s learning.