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

偏门js面试题又一道 #50

Open
hax opened this issue Nov 29, 2019 · 5 comments
Open

偏门js面试题又一道 #50

hax opened this issue Nov 29, 2019 · 5 comments

Comments

@hax
Copy link
Owner

hax commented Nov 29, 2019

这次的题目是这样的:

'use strict'
var o1 = {
  f: function () {}
}
var o2 = {
  f() {}
}

请问 o1.fo2.f 有哪些差异。

@Hugo-seth
Copy link

知道一点区别是,o2.f 可以使用 super,而 o1.f 则不行

@zhangenming
Copy link

toString?

@jincdream
Copy link

jincdream commented Dec 12, 2019

image

根据上图,会导致

image

@jzsn2018
Copy link

image

根据上图,会导致

image

这是有意设计成这种差异还是历史遗留问题?不是很明白这种差异,求解

@hax
Copy link
Owner Author

hax commented Sep 10, 2020

这是有意设计成这种差异还是历史遗留问题?

有意设计成这样的——「方法」不能作为构造器。

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

5 participants