1) In the following code, what is the reasoning behind making gameOfLive
a variable and not just function gameOfLife()
?
2) What is go
sure: to explain the syntax:
functions are first class objects in javascript, so you can put a function into a variable. thus the main part of this code is in fact a function definition stored in var gameOfLife, which could later be used by calling:
gameOfLife()
gol is an object (hash), and "init" is another example of the above syntax, except put directly into the "init" key in the "gol" hash. so that function in turn could be called by:
gol["init"](w,h)