DEV Community

Discussion on: Questions πŸ™‹

Collapse
 
anpos231 profile image
anpos231 • Edited

I'd say use ES6 classes. Sure the process of creating a class is slightly bigger than calling a function, but if you do it only sometimes, then there will be no difference for the performance, and you get much cleaner code.

Avoid creating new objects from classes inside loops though, calling a function is better in this case:

// Bad example
for (i=0; i < 1000; i++) {
  const c = new Something()
}
// Better example
for (i=0; i < 1000; i++) {
  const c = doSomething()
}

For all the other cases you are fine.

Collapse
 
naijadeveloper profile image
naijadeveloper

πŸ™‚πŸ™‚Thanks