Home > front end >  Is there a benefit of putting direct calculation result in typescript?
Is there a benefit of putting direct calculation result in typescript?

Time:04-08

Which of the following is efficient in typescript/javascript?

const sizeInBytes = 10 * 1024 * 1000;
const sizeInBytes = 10240000;

Is the latter more efficient than former?

CodePudding user response:

Any performance difference that you might see from this would be immeasurable compared to the rest of the things that your application will be doing. The first one is probably more meaningful, so you should use that for your code. Or even create named variables for each of those numbers. If you run your code through something like WebPack, it'll likely optimize it anyway.

  • Related