- 主题:When spec. says "DontEnum", just DontEnum.
今天下班时间到了,但是还留了一个悬疑在,在地铁上想到了。
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 123.116.41.*
如果没做过 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
>>> function fn(){}
>>> fn
fn()
>>> for(var i in fn){console.log(i)}
prototype
sbind
sbAEListener
bind
nadBind
看来的确是个问题了……
【 在 modico ().net() 的大作中提到: 】
: 今天下班时间到了,但是还留了一个悬疑在,在地铁上想到了。
: function fn(){}
: for (i in fn) ...
: ...................
--
FROM 123.116.124.114
我也试了一下,只有prototype 一个结果? firefox
function fn() {}
print(fn);
for(var i in fn) {print(i);}
结果:
Running...
function fn() { }
prototype
【 在 sly9 (= =b) 的大作中提到: 】
: 标 题: Re: When spec. says "DontEnum", just DontEnum.
: 发信站: 水木社区 (Tue Sep 22 22:54:18 2009), 站内
:
: >>> function fn(){}
: >>> fn
: fn()
: >>> for(var i in fn){console.log(i)}
: prototype
: sbind
: sbAEListener
: bind
: nadBind
:
: 看来的确是个问题了……
: 【 在 modico ().net() 的大作中提到: 】
: : 今天下班时间到了,但是还留了一个悬疑在,在地铁上想到了。
: : function fn(){}
: : for (i in fn) ...
: : ...................
:
: --
: ╔══╗╔╗ ╔╗╔╗
: ║ ═╣║║ ║╚╝║
: ╠═ ║║╚═╗╠═ ║
: ╚══╝╚══╝╚══╝
:
:
※ 修改:·zms 于 Sep 22 22:58:24 2009 修改本文·[FROM: 123.112.64.220]
: ※ 来源:·水木社区 newsmth.net·[FROM: 123.116.124.114]
--
修改:zms FROM 123.112.64.220
FROM 123.112.64.220
嗯,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
firebug啊= =b
【 在 withinsea (沐海~魔導奏器|歌の琴フォルテール) 的大作中提到: 】
: 这都啥…… =口=
: 你用的什么控制台?safari?
--
FROM 123.116.124.114
他这应该是被污染了的 。。
【 在 withinsea (沐海~魔導奏器|歌の琴フォルテール) 的大作中提到: 】
: 这都啥…… =口=
: 你用的什么控制台?safari?
--
FROM 202.108.36.*
obj.hasOwnProperty()?
【 在 modico ().net() 的大作中提到: 】
: 今天下班时间到了,但是还留了一个悬疑在,在地铁上想到了。
: function fn(){}
: for (i in fn) ...
: ...................
--
FROM 202.108.130.*
你想说什么呢
【 在 woodstudio (T字先一横再一竖) 的大作中提到: 】
: obj.hasOwnProperty()?
--
FROM 218.241.172.*