자바스크립트의 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>