两者之间有什么区别吗?
function MyFunc() {
// code...
}
Run Code Online (Sandbox Code Playgroud)
和
var MyFunc = function() {
// code...
};
Run Code Online (Sandbox Code Playgroud)
在JavaScript?
1)在下面的代码中,创建gameOfLive变量的原因是function gameOfLife()什么?
2)什么是gol?它看起来像一个数组,但我不熟悉语法或它所谓的.
我正在学习http://sixfoottallrabbit.co.uk/gameoflife/
if (!window.gameOfLife) var gameOfLife = function() {
var gol = {
body: null,
canvas: null,
context: null,
grids: [],
mouseDown: false,
interval: null,
control: null,
moving: -1,
clickToGive: -1,
table: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(''),
tableBack: null,
init: function(width, height) {
gol.body = document.getElementsByTagName('body')[0];
gol.canvas = document.createElement('canvas');
if (gol.canvas.getContext) {
gol.context = gol.canvas.getContext('2d');
document.getElementById('content').appendChild(gol.canvas);
gol.canvas.width = width;
gol.canvas.height = height;
gol.canvas.style.marginLeft = "8px";
gol.control = document.getElementById('gridcontrol');
gol.canvas.onmousedown = gol.onMouseDown;
gol.canvas.onmousemove = gol.onMouseMove;
gol.canvas.onmouseup …Run Code Online (Sandbox Code Playgroud)