JavaScript中的“ new”关键字是什么?
JavaScript中的new关键字是new运算符。它创建用户定义的对象类型的实例。
语法如下:
new constructor[([arguments])]
示例
让我们看一个例子来学习new运算符的用法:
<!DOCTYPE html>
<html>
<body>
<p id = "test"></p>
<script>
var dept = new Object();
dept.employee = "Amit";
dept.department = "Technical";
dept.technology ="Java";
document.getElementById("test").innerHTML =
dept.employee + " is working on " + dept.technology + " technology.";
</script>
</body>
</html>