1.Objects
Today i continued learning Javascript and learned about Objects,Object properties,constructors.
An object is used to store related data using key-value pairs
``javascript
let student = {
name: "Saravanan",
age: 33,
course: "JavaScript"
};
console.log(student);`
2.Reassigning a property
We can change the value of an object's property
`student.age = 34;
console.log(student.age);`
3.Constructor
A constructor function can be used to create multiple objects with the same structure.
`
function Student(name, age) {
this.name = name;
this.age = age;
}
let student1 = new Student("Saravanan", 33);
let student2 = new Student("Arun", 25);
console.log(student1);
console.log(student2);`
Top comments (0)