JavaScript Tutorial
JS Objects
Understanding Objects
Objects are collections of key-value pairs, representing complex data structures.
Creating Objects
Use object literals const obj = , constructors, or classes.
Methods and Properties
Access properties with dot notation obj.name and methods as functions within objects.
Examples
const user = { name: 'Alice', age: 25 };
user.email = 'alice@example.com';
console.log(user.name);
class Person {
constructor(name) { this.name = name; }
greet() { return 'Hi ' + this.name; }
}
console.log(new Person('Bob').greet());