简体   繁体   中英

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM