拷贝构造函数 示例
JavaScript构造函数属性 (JavaScript constructor property)
constructor property is used to get details of the array's constructor function, it returns the reference to the function.
constructor属性用于获取数组的构造函数的详细信息,它返回对该函数的引用。
Syntax:
句法:
array_name.constructor;
Examples:
例子:
Input:
var arr1 = [10, 20, 30, 40, 50];
Function call:
arr1.constructor;
Output:
function Array() { [native code] }
JavaScript Code to get the constructor details
JavaScript代码以获取构造函数详细信息
<html>
<head>
<title>JavaScipt Example</title>
</head>
<body>
<script>
var arr1 = [10, 20, 30, 40, 50];
var arr2 = ["Amit", "Ankur", "Akash"];
var arr3 = [];
document.write("Constructor of arr1: " + arr1.constructor + "<br>");
document.write("Constructor of arr2: " + arr2.constructor + "<br>");
document.write("Constructor of arr3: " + arr3.constructor + "<br>");
</script>
</body>
</html>
Output
输出量
Constructor of arr1: function Array() { [native code] }
Constructor of arr2: function Array() { [native code] }
Constructor of arr3: function Array() { [native code] }
翻译自: https://www.includehelp.com/code-snippets/array-constructor-property-with-example-in-javascript.aspx
拷贝构造函数 示例