Max Travis
Max Travis

Reputation: 1328

Is it some performance difference between dynamic and direct variable return in javascript?

So, lets imagine we have next functions structure:

1)

   const foo = (value) => {  // imperative code writing
     return value ? 1 : 0
   }

2)

   const bar = (value) => { // declarative code writing
    const boo = value ? 1 : 0

    return boo
   }

Can someone tell me is there is some performance, style or logic difference btw using such two styles of code writing in JavaScript? Or maybe one of them is really better for using?

Thanks!

Upvotes: 0

Views: 58

Answers (1)

James Gould
James Gould

Reputation: 4712

That'll be optimized out in the engine you're running the JavaScript in.

Even if it wasn't the performance hit will be so incredibly small that it's not worth worrying about.

Upvotes: 3

Related Questions