unknown_boundaries
unknown_boundaries

Reputation: 1590

Is there a benefit of putting direct calculation result in typescript?

Which of the following is efficient in typescript/javascript?

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

Is the latter more efficient than former?

Upvotes: 1

Views: 56

Answers (1)

StriplingWarrior
StriplingWarrior

Reputation: 156524

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.

Upvotes: 3

Related Questions