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>热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短