Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How to create JavaScript objects using new operator?
The new keyword in JavaScript is the new operator, which creates an instance of a user-defined object type.
Example
You can try to run the following code to create JavaScript objects using new operator −
<!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>
Output
Amit is working on Java technology.
Advertisements
