Từ khóa new trong JavaScript là toán tử new. Tạo instance của kiểu đối tượng do người dùng định nghĩa.
Cú pháp:
new constructor[([arguments])]
Ví dụ
Xem ví dụ học cách dùng toán tử 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>