![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the 'new' keyword in JavaScript to create an object and how to access values?
The new keyword creates an object in JavaScript. To access values, use the dot notation. Following is the code −
Example
function newObjectCreation() { this.firstName = "John"; } var newObject = new newObjectCreation(); newObject.firstName="David"; console.log("The first name="+newObject.firstName);
To run the above program, you need to use the following command −
node fileName.js.
Here, my file name is demo134.js
Output
This will produce the following output −
PS C:\Users\Amit\JavaScript-code> node demo134.js The first name=David
Advertisements