在对象初始值设定项中设置属性时不再调用setter:这是什么意思? [英] Setters are no longer called when setting properties in object initializers: what does this mean?
问题描述
在此 JS MDN 页面上写道:
JavaScript 1.8.1 note
从JavaScript 1.8.1开始,在对象和数组
初始值设定项中设置属性时,setter的调用次数不会超过
。
Starting in JavaScript 1.8.1, setters are no longer called when setting properties in object and array initializers.
我无法弄清楚这是告诉我的。
I just can't figure out what this is trying to tell me.
推荐答案
我认为这是指JSON劫持的问题。看看
I think this refers to the issue of JSON hijacking. Have a look at
- 是否有可能在现代浏览器上进行JSON劫持?
- http://incompleteness.me/blog/2007/03/05/json-is-not-as-safe-as -people-think-it-is /
- http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx , http://haacked.com/archive/2009/06/25/ json-hijacking.aspx
- http://hackademix.net/2009/01/13/you-dont-know-what-my-twitter-leaks/
- Is it possible to do 'JSON hijacking' on modern browser?
- http://incompleteness.me/blog/2007/03/05/json-is-not-as-safe-as-people-think-it-is/
- http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx, http://haacked.com/archive/2009/06/25/json-hijacking.aspx
- http://hackademix.net/2009/01/13/you-dont-know-what-my-twitter-leaks/
重新发布我的答案来自这个已删除的问题:
To repost my answer from this deleted question:
根据规范,两者都不是阵列( EcmaScript 5.1 $ b $b§11.1.4 )或对象文字
( EcmaScript5.1§11.1.5)应为
hijackable:
According to the specification, neither Array (EcmaScript 5.1 §11.1.4) nor Object literals (EcmaScript 5.1 §11.1.5) should be hijackable:
- 他们称具有该名称的标准内置构造函数,而不是你可能在
window.Array
或覆盖了窗口。对象
- 他们使用[[defineOwnProperty]],它绝对不会处理
Object.prototype
上的任何setter。
- They call "the standard built-in constructor with that name", not what you might have overwritten at
window.Array
orwindow.Object
- They use [[defineOwnProperty]], which does absolutely not take care of any setters on
Object.prototype
.
如今,在ES 5.1兼容的浏览器中,这不再是一个问题。
Nowadays, this should not be an issue any more in ES 5.1-compliant browsers.
这篇关于在对象初始值设定项中设置属性时不再调用setter:这是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!