【发布时间】:2011-08-05 18:34:15
【问题描述】:
在浏览器体验中,编程的构造函数用于在该环境中生成工件。
- 是否有所有预定义的原始构造函数的完整列表?
- 某些构造函数是特定浏览器(Chrome、Opera、Safari 等)独有的吗?
- 每个构造函数的参数类型、顺序和含义在浏览器之间是否相同?
以 FireFox 为例:
javascript:
alert([
"using browser environment: \n"+window.navigator.userAgent,
new Array(), new Boolean(), new Date(), new Function(),
new Number(), new Object(), new RegExp(), new String(),
new Error(), new Image(), new Option(),
] . join("\n\n"));
生成:(内容空洞的工件是不可见的)
使用浏览器环境:
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3
假
2011 年 8 月 5 日星期五 11:25:15 GMT-0400(美国东部标准时间)
函数匿名(){}
0
[对象对象]
/(?:)/
错误
[对象 HTMLImageElement]
[对象 HTMLOptionElement]
FireFox 还有哪些其他基本构造函数(如果有的话)?
参考:
Where is the Documentation for all of the Javascript HTML Element Constructors?
Where are constructors such as, `new Image()` and `new Option()`, documented?
以下缺失的参考文献是疏忽。感谢TeslaNick's answer 促使他们加入。
Global Object constructors - MDN Docs
constructor - MDN Docs
【问题讨论】:
标签: javascript dom