Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Day3:写出执行结果,并解释原因 #39

Open
Genzhen opened this issue Jun 22, 2020 · 5 comments
Open

Day3:写出执行结果,并解释原因 #39

Genzhen opened this issue Jun 22, 2020 · 5 comments

Comments

@Genzhen
Copy link
Collaborator

Genzhen commented Jun 22, 2020

var min = Math.min();
max = Math.max();
console.log(min < max);
// 写出执行结果,并解释原因

每日一题会在下午四点在交流群集中讨论,五点小程序中更新答案
欢迎大家在下方发表自己的优质见解
二维码加载失败可点击 小程序二维码

扫描下方二维码,收藏关注,及时获取答案以及详细解析,同时可解锁800+道前端面试题。

@Genzhen
Copy link
Collaborator Author

Genzhen commented Jun 22, 2020

答案
false

解析

  • 按常规的思路,这段代码应该输出 true,毕竟最小值小于最大值。但是却输出 false
  • MDN 相关文档是这样解释的
    • Math.min 的参数是 0 个或者多个,如果多个参数很容易理解,返回参数中最小的。如果没有参数,则返回 Infinity,无穷大。
    • 而 Math.max 没有传递参数时返回的是-Infinity.所以输出 false

@Genzhen Genzhen closed this as completed Jul 20, 2020
@Genzhen Genzhen reopened this Jul 29, 2020
@Kinice
Copy link

Kinice commented Aug 31, 2020

个人感觉这题意义不大。。

@Genzhen
Copy link
Collaborator Author

Genzhen commented Sep 3, 2020

个人感觉这题意义不大。。

对于知识来说,多了解一点总没有坏处

@Kinice
Copy link

Kinice commented Sep 3, 2020

个人感觉这题意义不大。。

对于知识来说,多了解一点总没有坏处

说得没错~

@yuanhaotian
Copy link

还是得看,因为一些公司就面这,做为附加题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants