JavaScript constructor属性
来源:互联网 发布:松下有没有淘宝旗舰店 编辑:程序博客网 时间:2024/06/07 05:34
Definition and Usage
定义与用法The constructor property is a reference to the function that created an object.
constructor属性是所建立对象的函数参考Syntax
语法object.constructorExample 1
举例In this example we will show how to use the constructor property:
在这个举例中我们将展示如何使用constructor属性:<script type="text/javascript">var test=new Array()
if (test.constructor==Array)
{document.write("This is an Array")}
if (test.constructor==Boolean)
{document.write("This is a Boolean")}
if (test.constructor==Date)
{document.write("This is a Date")}
if (test.constructor==String)
{document.write("This is a String")}</script>The output of the code above will be:
输出结果为:This is an ArrayExample 2
举例2In this example we will show how to use the constructor property:
在这个举例中我们将展示如何使用constructor属性:<script type="text/javascript">function employee(name,jobtitle,born)
{
this.name=name
this.jobtitle=jobtitle
this.born=born
}var fred=new employee("Fred Flintstone","Caveman",1970)document.write(fred.constructor)</script>The output of the code above will be:
输出结果为:function employee(name, jobtitle, born)
{this.name = name; this.jobtitle = jobtitle; this.born = born;}Try-It-Yourself Demos
尝试与演示constructor - example 1
In this example we will show how to use the constructor property.
在这个举例中我们将展示如何使用constructor属性constructor - example 2
In this example we will show how to use the constructor property.
在这个举例中我们将展示如何使用constructor属性
http://www.w3pop.com/learn/view/doc/jsref_constructor_array/
- JavaScript constructor属性
- javascript constructor 属性
- JavaScript constructor属性
- JavaScript constructor 属性
- javascript constructor属性
- JavaScript constructor 属性
- javascript constructor属性
- JavaScript的constructor属性
- 浅谈javascript中的constructor属性。
- JavaScript类和继承:constructor属性
- JavaScript类和继承:constructor属性
- JavaScript类和继承:constructor属性
- JavaScript类和继承:constructor属性
- JavaScript类和继承:constructor属性
- JavaScript类和继承:constructor属性
- Javascript属性constructor/prototype的底层原理
- Javascript 的构造函数和constructor属性
- JavaScript Object.prototype.constructor属性详解
- 常见的数组之间的转换。List Set Array!
- 笔试题
- DB2常用语句总结
- 123
- 浙江大学教授郑强的经典语录
- JavaScript constructor属性
- 关于网站cookie的读取,写入,清楚!
- Android画图学习总结(一)——类的简介
- DB2数据库中SELECT语句高级用法
- 学java几年了,感慨颇深啊
- J2EE面试题集锦(附答案)
- 升级 perl 模块 以及编码转换
- Android画图学习总结(二)——Bitmap
- 多表建立视图,用于站内搜索!