- 主题:When spec. says "DontEnum", just DontEnum.
如果没做过 fn.prototype = { .... } 的话应该算 bug 了……
【 在 modico ().net() 的大作中提到: 】
: 今天下班时间到了,但是还留了一个悬疑在,在地铁上想到了。
: function fn(){}
: for (i in fn) ...
: firefox 把 "prototype" 属性也 for in 出来了,导致我的程序出了问题。
: 我翻了ecma-262,在15.3.3.1里说到Function.prototype有DontEnum的属性,
: 所以我觉得firefox不该把 "prototype" for in 出来。
: 回家在几个浏览器上测试的结果是:
: IE, Opera 不会;
: Firefox, Chrome, Safari 都会。
--
FROM 221.221.219.245
嗯,constructor, length 之类的 DontEnum 还是起作用了……
而且它还不是没检查,而是 DontEnum 就是被设成了false
var f = function () { };
console.log(f.propertyIsEnumerable('prototype'));
console.log(f.propertyIsEnumerable('constructor'));
console.log(f.propertyIsEnumerable('length'));
输出
true
false
false
【 在 zms (小美) 的大作中提到: 】
: 我也试了一下,只有prototype 一个结果? firefox
: function fn() {}
: print(fn);
: ...................
--
修改:withinsea FROM 221.221.219.245
FROM 221.221.219.245
【 在 sly9 (= =b) 的大作中提到: 】
: >>> function fn(){}
: >>> fn
: fn()
: >>> for(var i in fn){console.log(i)}
: prototype
: sbind
: sbAEListener
: bind
: nadBind
这都啥…… =口=
你用的什么控制台?safari?
: 看来的确是个问题了……
--
FROM 221.221.219.245