Lea Verou 2/25/2009

"Appearances can be deceiving Mr. Anderson" - a.k.a. short code is not always fast code

Read Original

This article analyzes four JavaScript methods for checking String and Number types, comparing performance through benchmarks. It reveals that while some concise methods appear elegant, they can be significantly slower than alternatives like Object.prototype.toString or typeof. The author concludes that performance testing is crucial and recommends the most reliable method for bulletproof type checking.

"Appearances can be deceiving Mr. Anderson" - a.k.a. short code is not always fast code

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week

1
ServiceNow and Microsoft Copilot
Marius Sandbu 1 votes
2
The Learning Loop and LLMs
Martin Fowler 1 votes