Skip to content
Advertisement

Tag: typeof

When iterating over values, why does typeof(value) return “string” when value is a number? JavaScript

I’m using Google Chrome for this test: Contrary to intuition, the first loop alerts “string” three times, while the second loop alerts “number” three times. I was expecting both loops to alert “number” three times. How is the first loop implemented in JavaScript? In other words, if the for-each is syntactic sugar, what is its equivalent using a standard loop?

Advertisement