HOME C C++ PYTHON JAVA HTML CSS JAVASCRIPT BOOTSTRAP JQUERY REACT PHP SQL AJAX JSON DATA SCIENCE AI

JavaScript Objects

Object Definition

In JavaScript, objects are one of the most important data types. They are used to store collections of data in the form of key-value pairs. Objects in JavaScript are dynamic, meaning properties can be added or removed from them at any time.

Example
let person = {
    name: 'John',
    age: 30,
    city: 'New York'
};
              

Object Methods:

You can also define functions as properties of an object:

Example
let person = {
    name: 'John',
    greet: function() {
        console.log('Hello, my name is ' + this.name);
    }
};