en.javascript.info icon indicating copy to clipboard operation
en.javascript.info copied to clipboard

__proto__ deprecation

Open bevand10 opened this issue 2 years ago • 0 comments

https://github.com/javascript-tutorial/en.javascript.info/blob/285083fc71ee3a7cf55fd8acac9c91ac6f62105c/1-js/99-js-misc/01-proxy/article.md?plain=1#L712

As per MDN and ECMASCRIPT, use of this approach seems to be deemed legacy and will at some point be withdrawn from browsers.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/proto

https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-object.prototype.proto

The alternative seems to be Object.create ?

// considered bad practice
let admin = {
  __proto__: userProxy,
  _name: "Admin"
};

// recommended
let admin = Object.create(userProxy);
admin._name = 'Admin'

bevand10 avatar Oct 27 '23 14:10 bevand10