dispatchEvent也应该是一个函数的最后一条语句? [英] Should DispatchEvent be the last statement of a function?

查看:138
本文介绍了dispatchEvent也应该是一个函数的最后一条语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

dispatchEvent也应该必须是任何函数的最后一条语句?

Should dispatchEvent must be the last statement of any function ?

推荐答案

在调用dispatchEvent,所有处理该事件立即在函数体的地方则dispatchEvent调用运行的其余部分之前调用。这是否意味着你需要调用dispatchEvent作为函数体的最后一件事?只有当code,它是则dispatchEvent调用后莫名其妙地依赖于某种东西,当处理器运行将发生重大不利变化。

When you call dispatchEvent, all handlers for that event are immediately called before the rest of the function body where dispatchEvent was called runs. Does that mean that you need to call dispatchEvent as the last thing in a function body? Only if the code that is after the dispatchEvent call somehow depends on something that will be adversely changed when the handlers run.

这篇关于dispatchEvent也应该是一个函数的最后一条语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆