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

关于initListen方法中的逻辑咨询 #32

Open
asakurayoh1987 opened this issue Nov 19, 2016 · 0 comments
Open

关于initListen方法中的逻辑咨询 #32

asakurayoh1987 opened this issue Nov 19, 2016 · 0 comments

Comments

@asakurayoh1987
Copy link

asakurayoh1987 commented Nov 19, 2016

Messenger.prototype.initListen的方法中有如下代码逻辑:
for(var i = 0; i < self.listenFunc.length; i++){
if (prefix + name === self.prefix + self.name) {
self.listenFunci;
}
}
这里可以把if的判断放到外面吗,针对一个回调时,prefix和name是不变的了吧,应该只要判断一次就可以进行for循环了,而现在这种写法是在每次循环时都要判断一次,有什么深意吗?

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

1 participant