This article records Javascript questions that I think is important but often ignored by people.

# Array.prototype.map()

The map() method creates a new array with the results of calling a provided function on every element in the calling array. See more in Array.prototype.map() | MDN.

For each iteration map, parseInt() passes two parameters: string and index. So the code actually executed is:

This will return

So:

In order to achieve the function we want, we could do this:

# extends

## ES5

• Prototype Inheritance

We can find that the whole inheritance process is delegated through the pointing between prototype chains until the final result of “constructed by constructors” is formed.

• Constructor Inheritance

The key of constructor inheritance is to get the members and methods of the parent class on the newly created objects in the future by calling the parent class inside the child class, that is, by using the apply() or call() method.

Donate