Answers for "what is constructor function in javascript"

19

js constructor syntax

var MyConstructor = function(p1, p2, p3){
  this.p1 = p1;
  this.p2 = p2;
  this.p3 = p3;
};
Posted by: Guest on November-08-2021
0

why do we use Object Constructors

function Tree(name) {
  this.name = name
}

let theTree = new Tree('Redwood')
console.log('theTree.constructor is ' + theTree.constructor)
Posted by: Guest on June-08-2020

Code answers related to "what is constructor function in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language