Skip to content

经典面试题?? #4

@yangchendoit

Description

@yangchendoit

[1,2,3].map(parseInt)

关键点是对parseInt的掌握

parseInt(string, radix) 第一个参数为被解析的值,第二个为进制,默认为10

同时map(callback(currentValue, index, array), this)

很显然,在[1,2,3].map(parseInt)parseInt接受到的参数是currentValue, index,对于parseInt接受到的第二参数radix而言,是有一定范围的[2,36]和特殊值0
image
传送门
所以最后的结果是返回[1, NaN, NaN]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions