Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript class constructor

class Person {
  constructor(name, age) {
    this.name = name;
    this.age = age;
  }
}

const person = new Person("John Doe", 23);

console.log(person.name); // expected output: "John Doe"
 
PREVIOUS NEXT
Tagged: #javascript #class #constructor
ADD COMMENT
Topic
Name
7+8 =