The following 2 blocks of code:
const Game = { start: () => { ...run some logic; return true; }, stop: () => { ...run some logic; return false; } }
class Game { static start() { ...run some logic; return true; } static stop() { ...run some logic; return false; } }
Both works when running Game.start()
or Game.stop()
.
Are there any pros/cons for either one of them?
https://stackoverflow.com/questions/66501542/javascript-class-static-method-vs-function March 06, 2021 at 09:33AM
没有评论:
发表评论