There are some conventions when it comes to using brackets in JavaScript , but do they actually get treated differently when the brackets are used to invoke.
Is fn ()
different to fn()
in any way , except to the human reader?
Further, is there a difference between (fn)()
and fn()
, and if yes which of these to would fn ()
resemble?
For this question fn
can be any function function fn() {}
or var fn = function () {}
EDIT : This question isn't "Will they have the same result?", it is about if/how JavaScript compilers treat them.
没有区别, fn () = fn() = (fn)()
但是function fn() {} != var fn = function() {}
因为提升是如何工作的。
不, fn()
、 fn ()
、 (fn)()
和(fn) ()
都是同一个意思。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.