Snippets Collections
class ClassMates{
	constructor(name,age){
    	this.name=name;
      	this.age=age;
    }
  	displayInfo(){
    	return this.name + "is " + this.age + " years old!";
    }
}

let classmate = new ClassMates("Mike Will",15);
classmate.displayInfo();  // result: Mike Will is 15 years old!
class Pencil {
  constructor(price) {
    this.price = price;
  }

  isExpensive() {
    return this.price >= 10;
  }
}

//usage
const bic = new Pencil(3);
bic.isExpensive();
star

Tue Aug 08 2023 18:08:56 GMT+0000 (Coordinated Universal Time)

#javascript #class #oop #this
star

Wed Apr 05 2023 16:11:13 GMT+0000 (Coordinated Universal Time) https://codetogo.io/how-to-define-a-class-in-javascript/

#javascript #class #generate #constructor #this
star

Sun Jun 19 2022 08:35:06 GMT+0000 (Coordinated Universal Time) test.com

#how #this #works

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension