1771771771
Denoβ€’4y agoβ€’
6 replies
177177177

About performance

if a function takes only one paramater
and i pass unnecessary additional parameters would it affect the performance of just the function part of the code?
function echo(sentence) {
  console.log(sentence)
}

echo('hello')

echo('hello', 'bye', 'okay')

this is what im caonfused abt

i have a object, every value is a function that takes the same parameter payload except only one value that takes an additional second parameter args

i want to know which way from these two would perform better
const handler = {
  READY: (payload, args) => {},
  GUILD_CREATE: (payload) => {},
  MESSAGE_CREATE: (payload) => {}.
  // ...about 30 more
}


// should i do this
handler[eventName](payload, args)

// or this
if (eventName === 'READY') handler[eventName](payload, args)
else handler[eventName](payload)
Was this page helpful?