Is there a difference between
myProperty: myFunction()
or
myProperty: { ... }
or is the latter the same as the former?
They are basically the same. In the latter version, any explicit return gives the property its value. If there is no return, the last expression in the block becomes the property value.
I prefer the first version when working exclusively with a JS expression and use the second form where the calculation takes some imperative logic. I always use explicit returns in the second form.
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.