-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjects.js
More file actions
43 lines (32 loc) · 966 Bytes
/
objects.js
File metadata and controls
43 lines (32 loc) · 966 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// console.log(this);
// const car = {
// make: "Mercedes",
// model: "Gle",
// move: function () {
// console.log(this)
// console.log("moving")
// } // this one is json method to create objects
// }
// car.move();
// class Car {
// constructor(model, make) {
// console.log(this)
// this.make = make;
// this.model = model;
// }
// }
// const car1 = new Car("BMW", "X5")
// console.log(car1)
// js does not support constructor overloading
// const Car = function(){
// console.log(this)
// }
// Car()
// const Car = function(make,model,year){ // this is function or variable which is returning object
// this.make = make;
// this.model = model;
// this.year = year;
// return this
// } // this method of creating object is factory method
// const car1 = new Car("Mercedes Benz","GTR pro",2822); // when we use new keyword it will create an object
// console.log(car1);