Why are Number.parseInt and global parseInt different?

The MDN section Number.parseInt says that:

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

.. but the following code gives false

for the latest firefox version

console.log(Number.parseInt == parseInt)

      

So they are the same?

+3


source to share


1 answer


AFAIK your comparison (when applied to functions) checks if it is the same instance of a function, which it is not - they just have similar content (code) inside. You can easily test it by specifying your own 2 functions that just contain similar code, eg. "{alert ('hi')}" in both. You will see that they are not "=="



+1


source







All Articles