JS - constructor function

Minsoo·2021년 7월 28일
0

JS

목록 보기
5/9
post-thumbnail

☄️ Constructor function

📍 Various way of creating obj.

  • object literal syntax
    const obj1= {}
  • object constructor syntax
    const obj2 = new Object()
  • object.create method
  • class ES6

📍 "Constuctor function"

const person = new Person('minsoo', '23');

function Person(name, age) {
 //this = {};
 this.name = name,
 this.age = age
 //return this;
 }
  • It calls "Constuctor function"
  • It create 'this' obj and return the'this' behind the scene.
profile
Hello all 👋🏻 📍London

0개의 댓글