
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
What is 'new' Operator in JavaScript?
The new keyword in JavaScript is the new operator. It creates an instance of a user-defined object type.
Syntax
Here’s the syntax −
new constructor[([arguments])]
Example
Let us see an example to learn about the usage of new operator −
<!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>
- Related Articles
- The new operator in JavaScript
- What is the difference between new operator and object() constructor in JavaScript?
- Difference between "new operator" and "operator new" in C++?
- Creating JavaScript constructor using the “new” operator?
- What is increment (++) operator in JavaScript?
- What is decrement (--) operator in JavaScript?
- What is Conditional Operator (?:) in JavaScript?
- What is typeof Operator in JavaScript?
- What is Modulus Operator (%) in JavaScript?
- What is Multiplication Operator (*) in JavaScript?
- What is Addition Operator (+) in JavaScript?
- What is Assignment Operator (=) in JavaScript?
- What is Comma Operator (,) in JavaScript?
- What is spread Operator (...) in JavaScript?
- What is Subtraction Operator (-) in JavaScript?

Advertisements