Edit:
I am not 100% sure why parseInt
not a String
method, except that it can be run on anything. It seems that it may be part of Math
, but it is also not a mathematical operation.
Edit end
parseInt
is a global object method. In the browser, the global window
object. You can call window.parseInt()
, but the JS mechanism allows you to make calls with global methods.
However, there is a certain cost to this, as the engine must scan a chain of regions looking for parseInt
definitions. As a rule, if I make a single to call such a method within the scope, I will refer to it as global:
var foo = function (someString) { var bar;
If my code needs to make more than one method call within the scope, I localize it and use the link:
var foo = function (someString, someOtherString) { var parseInt = window.parseInt, bar, baz;
source share