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>