易截截图软件、单文件、免安装、纯绿色、仅160KB

JavaScript constructor属性

Definition and Usage
定义与用法The constructor property is a reference to the function that created an object.
constructor属性是所建立对象的函数参考Syntax
语法object.constructor
Example 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 Array
Example 2
举例2
In 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与C# Windows应用程序交互方法

一、建立网页
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<script language="javascript" type="text/javascript">
<!-- 提供给C#程序调用的方法 -->
function messageBox(message)
{
alert(message);
}
</script>
</head>
& ......

一次惊险的javascript经历,汗,现在想想都后怕

在开发一个缴费交易时,先发送查询请求到系统A,系统A返回一个字符串格式的欠费金额,因为是定长的,所以都是前补0,本来需要先做处理的,但是由于查询结果如果是欠费的,客户发起缴费交易时,会送给系统B的格式,与系统A返回的是一样的,因此就原样保存然后上送,可是在系统测试时,却发现了一个奇怪的现象,系统A返回的查 ......

用javascript删除当前行,添加行

删除行
<script>  
  function   del(obj)  
  {  
        obj.parentNode.parentNode.removeNode(true);  
  }    
  </script>  
  <body& ......

107条Javascript的常用语句

1.         document.write( " "); 输出语句
2.JS中的注释为//
3.传统的HTML文档顺序是:document- >html- >(head,body)
4.一个浏览器窗口中的DOM顺序是:window- >(navigator,screen,history,location,document)
5.得到表单中元素的名称和值:document.getElementById( "表单 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号