覆盖数组构造不影响[],对吧? [英] Overwriting the Array constructor does not affect [], right?

查看:64
本文介绍了覆盖数组构造不影响[],对吧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚看了这样的: <一个href=\"http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx\">http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx

I just read this: http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-json-vulnerability.aspx

我是IM pression根据该覆盖的 对象 阵列 如果您选择创建 数组时使用的构造函数只有一个效果 / 对象 ,但据该文章,也对文学创作的影响( {} [] )...

I was under the impression that overwriting Object or Array only had an effect if you chose to use the constructor functions when creating arrays/objects, but, according to that article, it also has an effect on literal creation ({} and [])...

我的逻辑是:

Array = function(){ alert('Hi'); };

[1,2,3,4,5];
([1,2,3,4,5]);
var a = [1,2,3,4,5];

// ...
// ... Nothing is alerted

所以,我是不是要疯了,还是有一些具体实现的怪癖,我不知道的?

So, am I going crazy or are there some implementation-specific quirks I'm not aware of?

推荐答案

据我知道这是ECMAScript规范的问题,并固定在一年前所有主流浏览器。 这里是您链接到最相关的链接的链接;)

As far as I know this is an issue with the ECMAScript specification and was fixed in all major browsers over a year ago. Here is a link that links you to the most relevant links ;)

但要真正回答你的问题,是的,对象阵列构造也援引了文字创作。在修复的浏览器中实现仅仅通过自定义脚本,使这些(及其他)不变,使他们不能被覆盖。

But to actually answer your question, yes, the Object and Array constructors are also invoked for literal creations. The fix browsers implemented just made these (and others) constant so they can't be overridden by custom scripts.

这篇关于覆盖数组构造不影响[],对吧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆