拷贝构造函数 示例_数组构造函数属性以及JavaScript中的示例

拷贝构造函数 示例

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

拷贝构造函数 示例

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值