DEV Community

Discussion on: Different type of functions in JavaScript

jaamaal95 profile image
Md. Jamal Uddin Author

here is an example Function constructor with implementing a class and you know JavaScript class is a syntactic sugar over the function structure.

class Animal {
  constructor(name, energy) { = name = energy
  eat(amount) {
    console.log(`${} is eating.`) += amount
  sleep() {
    console.log(`${} is sleeping.`) += length
  play() {
    console.log(`${} is playing.`) -= length

const leo = new Animal('Leo', 7)

wanna know more, please check out this stackoverflow thread