Object.defineProperty polyfill

时光总嘲笑我的痴心妄想 提交于 2019-11-29 02:35:46

For clarity, you might want to stick with standard terminology and name your routines defineDataProperty and defineAccessorProperty.

Also, your enumerable: enumerable || true is going to result in a value of true even if the caller passes in false...

Anyway, to get down to the question at hand: you can't do this in IE8. It is said that defineProperty works in IE8 but only on DOM objects. There are ugly hacks for IE7 and below involving using the onpropertychanged event on DOM objects. All of this has been gone over in some detail in other questions, such as Cross-browser Getter and Setter, JavaScript getter support in IE8, and many others.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!