Answers for "constructor function"

8

javascript constructor object

function Person(first, last, age, eye) {
  this.firstName = first;
  this.lastName = last;
  this.age = age;
  this.eyeColor = eye;
}
Posted by: Guest on December-01-2019
9

js constructor object

function Car(make, model, year) {
  this.make = make;
  this.model = model;
  this.year = year;
}

var car1 = new Car('Eagle', 'Talon TSi', 1993);

console.log(car1.make);
// expected output: "Eagle"
Posted by: Guest on December-03-2019
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
0

constructor function

// constructor function
function Person () {
    this.name = 'John',
    this.age = 23
}

// create an object
const person = new Person();
Posted by: Guest on May-02-2021

Code answers related to "constructor function"

Browse Popular Code Answers by Language