eridal
eridal

Reputation: 1338

why Number.parseInt and global's parseInt are differents?

In MDN's Number.parseInt section, it says that:

The Number.parseInt() method parses a string argument and returns an integer of the specified radix or base. This method behaves identically to the global function parseInt() and is part of ECMAScript 6 (its purpose is modularization of globals).

.. but the following code yields false on latest firefox

console.log(Number.parseInt == parseInt)

So are they just the same?

Upvotes: 3

Views: 233

Answers (1)

Pelit Mamani
Pelit Mamani

Reputation: 2381

AFAIK your comparison (when applied to Functions) tests whether it's the exact same instance of Function, which is not - they just happen to have similar content (code) inside. You can easily test it by defining your own 2 functions that just happen to contain similar code, e.g. "{alert('hi')}" in both. You'll see they are not "=="

Upvotes: 1

Related Questions