Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

to fix a broken class oop javascript

function PrototypicalGreeting(greeting = "Hello", name = "World") {
  this.greeting = greeting
  this.name = name
}

PrototypicalGreeting.prototype.greet = function() {
  return `${this.greeting}, ${this.name}!`
}

const greetProto = new PrototypicalGreeting("Hey", "folks")
console.log(greetProto.greet())
Source by www.toptal.com #
 
PREVIOUS NEXT
Tagged: #fix #broken #class #oop #javascript
ADD COMMENT
Topic
Name
3+7 =