Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to recognize when to use : or = in JavaScript?
The colon (:) can be used when you want to define the property to an object while equal (=) can be used when you want to assign a value to a variable.
Example
Following is the code −
var studentDetails = {
"studentId": 101,
"studentName": "John",
"studentSubjectName": "Javascript",
"studentCountryName": "US"
}
console.log(studentDetails);
var firstName = "David";
console.log(firstName);
To run the above program, you need to use the below command −
node fileName.js.
Here, my file name is demo325.js.
Output
This will produce the following output −
PS C:\Users\Amit\javascript-code> node demo325.js
{
studentId: 101,
studentName: 'John',
studentSubjectName: 'Javascript',
studentCountryName: 'US'
}
DavidAdvertisements