JavaScript Reference/Javascript Properties/constructor

Материал из Web эксперт
Перейти к: навигация, поиск

"constructor" Example

    
<html>
<body>
<script language="javascript">
function function1(){
    var array = new Array("1", "2");
    alert(array.constructor); 
} 
</script>
<button onclick="function1();">Array Constructor</button>
</body>
</html>



"constructor" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |Array                           Boolean                       |
|                |Date                            Math                          |
|                |Number                          Object                        |
|                |String                                                        |
+----------------+--------------------------------------------------------------+



"constructor" Syntax and Note

Note:
Read-only property. 
returns the same string as the toSource() method.
    
Syntax:
    
objectName.constructor