JavaScript中的“新”运算符是什么?
JavaScript中的new关键字是new运算符。它创建用户定义的对象类型的实例。
语法
这是语法-
new constructor[([arguments])]
示例
让我们看一个例子来学习new操作符的用法-
<!DOCTYPE html>
<html>
<body>
<p id="test"> </p>
<script>
var dept = newObject();
dept.employee = "David";
dept.department = "Programming";
dept.technology = "C++";
document.getElementById("test").innerHTML =
dept.employee + "is working on " + dept.technology + " technology.";
</script>
</body>
</html>热门推荐
1 狗狗技能训练
5 如何训练狗狗笑
6 狗狗训练排便
9 狗狗响片训练
10 如何训练狗狗不捡食
11 狗狗尿训练
12 怎么训练狗狗找东西
13 狗狗训练站立
14 狗狗训练飞盘
15 鞍山狗狗训练
16 怎样训练泰迪狗狗谢谢
17 狗狗外出训练
18 怎么训练金毛狗狗大小便