Create new
Bindings
Transitions
Animations
Easing
Component composition
Context API
Special elements
Module context
Debugging
Miscellaneous
App.svelte
runes
This component is in runes mode.
To disable runes mode, add the following to the top of your component:
<svelte:options runes={false} />
999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
⌄
⌄
⌄
⌄
<script lang="ts">
// Grid size
const GRID_SIZE = 20;
const CELL_SIZE = 20;
// Game state
let direction = $state<'up' | 'down' | 'left' | 'right'>('right');
let snake = $state([[0, 0]]); // Array of [x, y] coordinates
let food = $state<[number, number]>([5, 5]);
let score = $state(0);
let gameOver = $state(false);
let gameLoopInterval = $state<number | null>(null);
// Derived values
let gameBoard = $derived.by(() => {
const board: ('empty' | 'snake' | 'food')[][] = Array(GRID_SIZE)
.fill('empty')
.map(() => Array(GRID_SIZE).fill('empty'));
// Place snake
snake.forEach(([x, y]) => {
if (x >= 0 && x < GRID_SIZE && y >= 0 && y < GRID_SIZE) {
board[y][x] = 'snake';
}
});
// Place food
board[food[1]][food[0]] = 'food';
return board;
});
// Game logic functions
function startGame() {
if (gameLoopInterval) return;
Error compiling component
WebAssembly.instantiateStreaming(): value type opcode @+13
999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
⌄
⌄
⌄
⌄
import 'svelte/internal/disclose-version';
import * as $ from 'svelte/internal/client';
// Game logic functions
function startGame(_, gameLoopInterval, resetGame, gameLoop) {
if ($.get(gameLoopInterval)) return;
resetGame();
$.set(gameLoopInterval, $.proxy(window.setInterval(gameLoop, 150)));
}
var root_2 = $.template(`<div></div>`);
var root_3 = $.template(`<div class="game-over svelte-1uq0eai"><h2>Game Over!</h2> <p> </p> <button class="svelte-1uq0eai">Play Again</button></div>`);
var root_5 = $.template(`<button class="start-button svelte-1uq0eai">Start Game</button>`);
var root = $.template(`<div class="game-container svelte-1uq0eai"><div class="score svelte-1uq0eai"> </div> <div class="game-board svelte-1uq0eai"></div> <!></div>`);
export default function App($$anchor, $$props) {
$.push($$props, true);
// Grid size
const GRID_SIZE = 20;
const CELL_SIZE = 20;
// Game state
let direction = $.state('right');
let snake = $.state($.proxy([[0, 0]])); // Array of [x, y] coordinates
let food = $.state($.proxy([5, 5]));
let score = $.state(0);
let gameOver = $.state(false);
let gameLoopInterval = $.state(null);
// Derived values
let gameBoard = $.derived(() => {
const board = Array(GRID_SIZE).fill('empty').map(() => Array(GRID_SIZE).fill('empty'));
// Place snake
$.get(snake).forEach(([x, y]) => {
if (x >= 0 && x < GRID_SIZE && y >= 0 && y < GRID_SIZE) {
result = svelte.compile(source, {
generate: ,
});99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
.game-container.svelte-1uq0eai {
display: flex;
flex-direction: column;
align-items: center;
gap: 20px;
padding: 20px;
}
.score.svelte-1uq0eai {
font-size: 24px;
font-weight: bold;
}
.game-board.svelte-1uq0eai {
position: relative;
background-color: #f0f0f0;
border: 2px solid #333;
}
.cell.svelte-1uq0eai {
position: absolute;
box-sizing: border-box;
}
.cell.snake.svelte-1uq0eai {
background-color: #4CAF50;
border-radius: 4px;
}
.cell.food.svelte-1uq0eai {
background-color: #FF5722;
border-radius: 50%;
}
.game-over.svelte-1uq0eai {
Root {
css: StyleSheet {...}
- type: "StyleSheet"
- start: 3660
- end: 4687
- attributes: []
children: [...] (9)
Rule {...}
- type: "Rule"
prelude: SelectorList {...}
- type: "SelectorList"
- start: 3670
- end: 3685
children: [...] (1)
ComplexSelector {...}
- type: "ComplexSelector"
- start: 3670
- end: 3685
children: [...] (1)
RelativeSelector {...}
- type: "RelativeSelector"
- combinator: null
selectors: [...] (1)
ClassSelector {...}
- type: "ClassSelector"
- name: "game-container"
- start: 3670
- end: 3685
}
]- start: 3670
- end: 3685
}
]
}
]
}block: Block {...}
- type: "Block"
- start: 3686
- end: 3797
children: [...] (5)
Declaration {...}
- type: "Declaration"
- start: 3692
- end: 3705
- property: "display"
- value: "flex"
} Declaration {...}
- type: "Declaration"
- start: 3711
- end: 3733
- property: "flex-direction"
- value: "column"
} Declaration {...}
- type: "Declaration"
- start: 3739
- end: 3758
- property: "align-items"
- value: "center"
} Declaration {...}
- type: "Declaration"
- start: 3764
- end: 3773
- property: "gap"
- value: "20px"
} Declaration {...}
- type: "Declaration"
- start: 3779
- end: 3792
- property: "padding"
- value: "20px"
}
]
}- start: 3670
- end: 3797
} Rule {...}
- type: "Rule"
prelude: SelectorList {...}
- type: "SelectorList"
- start: 3801
- end: 3807
children: [...] (1)
ComplexSelector {...}
- type: "ComplexSelector"
- start: 3801
- end: 3807
children: [...] (1)
RelativeSelector {...}
- type: "RelativeSelector"
- combinator: null
selectors: [...] (1)
ClassSelector {...}
- type: "ClassSelector"
- name: "score"
- start: 3801
- end: 3807
}
]- start: 3801
- end: 3807
}
]
}
]
}block: Block {...}
- type: "Block"
- start: 3808
- end: 3857
children: [...] (2)
Declaration {...}
- type: "Declaration"
- start: 3814
- end: 3829
- property: "font-size"
- value: "24px"
} Declaration {...}
- type: "Declaration"
- start: 3835
- end: 3852
- property: "font-weight"
- value: "bold"
}
]
}- start: 3801
- end: 3857
} Rule {...}
- type: "Rule"
prelude: SelectorList {...}
- type: "SelectorList"
- start: 3861
- end: 3872
children: [...] (1)
ComplexSelector {...}
- type: "ComplexSelector"
- start: 3861
- end: 3872
children: [...] (1)
RelativeSelector {...}
- type: "RelativeSelector"
- combinator: null
selectors: [...] (1)
ClassSelector {...}
- type: "ClassSelector"
- name: "game-board"
- start: 3861
- end: 3872
}
]- start: 3861
- end: 3872
}
]
}
]
}block: Block {...}
- type: "Block"
- start: 3873
- end: 3961
children: [...] (3)
Declaration {...}
- type: "Declaration"
- start: 3879
- end: 3897
- property: "position"
- value: "relative"
} Declaration {...}
- type: "Declaration"
- start: 3903
- end: 3928
- property: "background-color"
- value: "#f0f0f0"
} Declaration {...}
- type: "Declaration"
- start: 3934
- end: 3956
- property: "border"
- value: "2px solid #333"
}
]
}- start: 3861
- end: 3961
} Rule {...}
- type: "Rule"
prelude: SelectorList {...}
- type: "SelectorList"
- start: 3965
- end: 3970
children: [...] (1)
ComplexSelector {...}
- type: "ComplexSelector"
- start: 3965
- end: 3970
children: [...] (1)
RelativeSelector {...}
- type: "RelativeSelector"
- combinator: null
selectors: [...] (1)
ClassSelector {...}
- type: "ClassSelector"
- name: "cell"
- start: 3965
- end: 3970
}
]- start: 3965
- end: 3970
}
]
}
]
}block: Block {...}
- type: "Block"
- start: 3971
- end: 4028
children: [...] (2)
Declaration {...}
- type: "Declaration"
- start: 3977
- end: 3995
- property: "position"
- value: "absolute"
} Declaration {...}
- type: "Declaration"
- start: 4001
- end: 4023
- property: "box-sizing"
- value: "border-box"
}
]
}- start: 3965
- end: 4028
} Rule {...}
- type: "Rule"
prelude: SelectorList {...}
- type: "SelectorList"
- start: 4032
- end: 4043
children: [...] (1)
ComplexSelector {...}
- type: "ComplexSelector"
- start: 4032
- end: 4043
children: [...] (1)
RelativeSelector {...}
- type: "RelativeSelector"
- combinator: null
selectors: [...] (2)
ClassSelector {...}
- type: "ClassSelector"
- name: "cell"
- start: 4032
- end: 4037
} ClassSelector {...}
- type: "ClassSelector"
- name: "snake"
- start: 4037
- end: 4043
}
]- start: 4032
- end: 4043
}
]
}
]
}block: Block {...}
- type: "Block"
- start: 4044
- end: 4104
children: [...] (2)
Declaration {...}
- type: "Declaration"
- start: 4050
- end: 4075
- property: "background-color"
- value: "#4CAF50"
} Declaration {...}
- type: "Declaration"
- start: 4081
- end: 4099
- property: "border-radius"
- value: "4px"
}
]
}- start: 4032
- end: 4104
} Rule {...}
- type: "Rule"
prelude: SelectorList {...}
- type: "SelectorList"
- start: 4108
- end: 4118
children: [...] (1)
ComplexSelector {...}
- type: "ComplexSelector"
- start: 4108
- end: 4118
children: [...] (1)
RelativeSelector {...}
- type: "RelativeSelector"
- combinator: null
selectors: [...] (2)
ClassSelector {...}
- type: "ClassSelector"
- name: "cell"
- start: 4108
- end: 4113
} ClassSelector {...}
- type: "ClassSelector"
- name: "food"
- start: 4113
- end: 4118
}
]- start: 4108
- end: 4118
}
]
}
]
}block: Block {...}
- type: "Block"
- start: 4119
- end: 4179
children: [...] (2)
Declaration {...}
- type: "Declaration"
- start: 4125
- end: 4150
- property: "background-color"
- value: "#FF5722"
} Declaration {...}
- type: "Declaration"
- start: 4156
- end: 4174
- property: "border-radius"
- value: "50%"
}
]
}- start: 4108
- end: 4179
} Rule {...}
- type: "Rule"
prelude: SelectorList {...}
- type: "SelectorList"
- start: 4183
- end: 4193
children: [...] (1)
ComplexSelector {...}
- type: "ComplexSelector"
- start: 4183
- end: 4193
children: [...] (1)
RelativeSelector {...}
- type: "RelativeSelector"
- combinator: null
selectors: [...] (1)
ClassSelector {...}
- type: "ClassSelector"
- name: "game-over"
- start: 4183
- end: 4193
}
]- start: 4183
- end: 4193
}
]
}
]
}block: Block {...}
- type: "Block"
- start: 4194
- end: 4452
children: [...] (9)
Declaration {...}
- type: "Declaration"
- start: 4200
- end: 4218
- property: "position"
- value: "absolute"
} Declaration {...}
- type: "Declaration"
- start: 4224
- end: 4232
- property: "top"
- value: "50%"
} Declaration {...}
- type: "Declaration"
- start: 4238
- end: 4247
- property: "left"
- value: "50%"
} Declaration {...}
- type: "Declaration"
- start: 4253
- end: 4285
- property: "transform"
- value: "translate(-50%, -50%)"
} Declaration {...}
- type: "Declaration"
- start: 4291
- end: 4333
- property: "background-color"
- value: "rgba(255, 255, 255, 0.9)"
} Declaration {...}
- type: "Declaration"
- start: 4339
- end: 4352
- property: "padding"
- value: "20px"
} Declaration {...}
- type: "Declaration"
- start: 4358
- end: 4376
- property: "border-radius"
- value: "8px"
} Declaration {...}
- type: "Declaration"
- start: 4382
- end: 4400
- property: "text-align"
- value: "center"
} Declaration {...}
- type: "Declaration"
- start: 4406
- end: 4447
- property: "box-shadow"
- value: "0 2px 10px rgba(0, 0, 0, 0.1)"
}
]
}- start: 4183
- end: 4452
} Rule {...}
- type: "Rule"
prelude: SelectorList {...}
- type: "SelectorList"
- start: 4456
- end: 4462
children: [...] (1)
ComplexSelector {...}
- type: "ComplexSelector"
- start: 4456
- end: 4462
children: [...] (1)
RelativeSelector {...}
- type: "RelativeSelector"
- combinator: null
selectors: [...] (1)
TypeSelector {...}
- type: "TypeSelector"
- name: "button"
- start: 4456
- end: 4462
}
]- start: 4456
- end: 4462
}
]
}
]
}block: Block {...}
- type: "Block"
- start: 4463
- end: 4625
children: [...] (7)
Declaration {...}
- type: "Declaration"
- start: 4469
- end: 4487
- property: "padding"
- value: "10px 20px"
} Declaration {...}
- type: "Declaration"
- start: 4493
- end: 4508
- property: "font-size"
- value: "16px"
} Declaration {...}
- type: "Declaration"
- start: 4514
- end: 4539
- property: "background-color"
- value: "#4CAF50"
} Declaration {...}
- type: "Declaration"
- start: 4545
- end: 4557
- property: "color"
- value: "white"
} Declaration {...}
- type: "Declaration"
- start: 4563
- end: 4575
- property: "border"
- value: "none"
} Declaration {...}
- type: "Declaration"
- start: 4581
- end: 4599
- property: "border-radius"
- value: "4px"
} Declaration {...}
- type: "Declaration"
- start: 4605
- end: 4620
- property: "cursor"
- value: "pointer"
}
]
}- start: 4456
- end: 4625
} Rule {...}
- type: "Rule"
prelude: SelectorList {...}
- type: "SelectorList"
- start: 4629
- end: 4641
children: [...] (1)
ComplexSelector {...}
- type: "ComplexSelector"
- start: 4629
- end: 4641
children: [...] (1)
RelativeSelector {...}
- type: "RelativeSelector"
- combinator: null
selectors: [...] (2)
TypeSelector {...}
- type: "TypeSelector"
- name: "button"
- start: 4629
- end: 4635
} PseudoClassSelector {...}
- type: "PseudoClassSelector"
- name: "hover"
- args: null
- start: 4635
- end: 4641
}
]- start: 4629
- end: 4641
}
]
}
]
}block: Block {...}
- type: "Block"
- start: 4642
- end: 4678
children: [...] (1)
Declaration {...}
- type: "Declaration"
- start: 4648
- end: 4673
- property: "background-color"
- value: "#45a049"
}
]
}- start: 4629
- end: 4678
}
]content: {...}
- start: 3667
- end: 4679
- styles: "\n .game-container {\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 20px;\n padding: 20px;\n }\n\n .score {\n font-size: 24px;\n font-weight: bold;\n }\n\n .game-board {\n position: relative;\n background-color: #f0f0f0;\n border: 2px solid #333;\n }\n\n .cell {\n position: absolute;\n box-sizing: border-box;\n }\n\n .cell.snake {\n background-color: #4CAF50;\n border-radius: 4px;\n }\n\n .cell.food {\n background-color: #FF5722;\n border-radius: 50%;\n }\n\n .game-over {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n background-color: rgba(255, 255, 255, 0.9);\n padding: 20px;\n border-radius: 8px;\n text-align: center;\n box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);\n }\n\n button {\n padding: 10px 20px;\n font-size: 16px;\n background-color: #4CAF50;\n color: white;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n }\n\n button:hover {\n background-color: #45a049;\n }\n"
- comment: null
}
}- js: []
- start: 2821
- end: 3658
- type: "Root"
fragment: Fragment {...}
- type: "Fragment"
nodes: [...] (5)
Text {...}
- type: "Text"
- start: 2819
- end: 2821
- raw: "\n\n"
- data: "\n\n"
} SvelteWindow {...}
- type: "SvelteWindow"
- start: 2821
- end: 2864
- name: "svelte:window"
attributes: [...] (1)
Attribute {...}
- type: "Attribute"
- start: 2836
- end: 2861
- name: "onkeydown"
value: ExpressionTag {...}
- type: "ExpressionTag"
- start: 2846
- end: 2861
expression: Identifier {...}
- type: "Identifier"
- start: 2847
- end: 2860
loc: {...}
start: {...}
- line: 130
- column: 26
}end: {...}
- line: 130
- column: 39
}
}- name: "handleKeydown"
}
}
}
]fragment: Fragment {...}
- type: "Fragment"
- nodes: []
}
} Text {...}
- type: "Text"
- start: 2864
- end: 2866
- raw: "\n\n"
- data: "\n\n"
} RegularElement {...}
- type: "RegularElement"
- start: 2866
- end: 3658
- name: "div"
attributes: [...] (1)
Attribute {...}
- type: "Attribute"
- start: 2871
- end: 2893
- name: "class"
value: [...] (1)
Text {...}
- start: 2878
- end: 2892
- type: "Text"
- raw: "game-container"
- data: "game-container svelte-1uq0eai"
}
]
}
]fragment: Fragment {...}
- type: "Fragment"
nodes: [...] (7)
Text {...}
- type: "Text"
- start: 2894
- end: 2897
- raw: "\n "
- data: "\n "
} RegularElement {...}
- type: "RegularElement"
- start: 2897
- end: 2936
- name: "div"
attributes: [...] (1)
Attribute {...}
- type: "Attribute"
- start: 2902
- end: 2915
- name: "class"
value: [...] (1)
Text {...}
- start: 2909
- end: 2914
- type: "Text"
- raw: "score"
- data: "score svelte-1uq0eai"
}
]
}
]fragment: Fragment {...}
- type: "Fragment"
nodes: [...] (2)
Text {...}
- type: "Text"
- start: 2916
- end: 2923
- raw: "Score: "
- data: "Score: "
} ExpressionTag {...}
- type: "ExpressionTag"
- start: 2923
- end: 2930
expression: Identifier {...}
- type: "Identifier"
- start: 2924
- end: 2929
loc: {...}
start: {...}
- line: 133
- column: 29
}end: {...}
- line: 133
- column: 34
}
}- name: "score"
}
}
]
}
} Text {...}
- type: "Text"
- start: 2936
- end: 2942
- raw: " "
- data: " "
} RegularElement {...}
- type: "RegularElement"
- start: 2942
- end: 3368
- name: "div"
attributes: [...] (2)
Attribute {...}
- type: "Attribute"
- start: 2947
- end: 2965
- name: "class"
value: [...] (1)
Text {...}
- start: 2954
- end: 2964
- type: "Text"
- raw: "game-board"
- data: "game-board svelte-1uq0eai"
}
]
} Attribute {...}
- type: "Attribute"
- start: 2966
- end: 3041
- name: "style"
value: [...] (5)
Text {...}
- start: 2973
- end: 2980
- type: "Text"
- raw: "width: "
- data: "width: "
} ExpressionTag {...}
- type: "ExpressionTag"
- start: 2980
- end: 3003
expression: BinaryExpression {...}
- type: "BinaryExpression"
- start: 2981
- end: 3002
loc: {...}
start: {...}
- line: 135
- column: 41
}end: {...}
- line: 135
- column: 62
}
}left: Identifier {...}
- type: "Identifier"
- start: 2981
- end: 2990
loc: {...}
start: {...}
- line: 135
- column: 41
}end: {...}
- line: 135
- column: 50
}
}- name: "GRID_SIZE"
}- operator: "*"
right: Identifier {...}
- type: "Identifier"
- start: 2993
- end: 3002
loc: {...}
start: {...}
- line: 135
- column: 53
}end: {...}
- line: 135
- column: 62
}
}- name: "CELL_SIZE"
}
}
} Text {...}
- start: 3003
- end: 3015
- type: "Text"
- raw: "px; height: "
- data: "px; height: "
} ExpressionTag {...}
- type: "ExpressionTag"
- start: 3015
- end: 3038
expression: BinaryExpression {...}
- type: "BinaryExpression"
- start: 3016
- end: 3037
loc: {...}
start: {...}
- line: 135
- column: 76
}end: {...}
- line: 135
- column: 97
}
}left: Identifier {...}
- type: "Identifier"
- start: 3016
- end: 3025
loc: {...}
start: {...}
- line: 135
- column: 76
}end: {...}
- line: 135
- column: 85
}
}- name: "GRID_SIZE"
}- operator: "*"
right: Identifier {...}
- type: "Identifier"
- start: 3028
- end: 3037
loc: {...}
start: {...}
- line: 135
- column: 88
}end: {...}
- line: 135
- column: 97
}
}- name: "CELL_SIZE"
}
}
} Text {...}
- start: 3038
- end: 3040
- type: "Text"
- raw: "px"
- data: "px"
}
]
}
]fragment: Fragment {...}
- type: "Fragment"
nodes: [...] (3)
Text {...}
- type: "Text"
- start: 3042
- end: 3047
- raw: "\n "
- data: "\n "
} EachBlock {...}
- type: "EachBlock"
- start: 3047
- end: 3359
expression: Identifier {...}
- type: "Identifier"
- start: 3054
- end: 3063
loc: {...}
start: {...}
- line: 136
- column: 11
}end: {...}
- line: 136
- column: 20
}
}- name: "gameBoard"
}body: Fragment {...}
- type: "Fragment"
nodes: [...] (3)
Text {...}
- type: "Text"
- start: 3074
- end: 3081
- raw: "\n "
- data: "\n "
} EachBlock {...}
- type: "EachBlock"
- start: 3081
- end: 3347
expression: Identifier {...}
- type: "Identifier"
- start: 3088
- end: 3091
loc: {...}
start: {...}
- line: 137
- column: 13
}end: {...}
- line: 137
- column: 16
}
}- name: "row"
}body: Fragment {...}
- type: "Fragment"
nodes: [...] (3)
Text {...}
- type: "Text"
- start: 3103
- end: 3112
- raw: "\n "
- data: "\n "
} RegularElement {...}
- type: "RegularElement"
- start: 3112
- end: 3333
- name: "div"
attributes: [...] (2)
Attribute {...}
- type: "Attribute"
- start: 3128
- end: 3147
- name: "class"
value: [...] (3)
Text {...}
- start: 3135
- end: 3140
- type: "Text"
- raw: "cell "
- data: "cell "
} ExpressionTag {...}
- type: "ExpressionTag"
- start: 3140
- end: 3146
expression: Identifier {...}
- type: "Identifier"
- start: 3141
- end: 3145
loc: {...}
start: {...}
- line: 139
- column: 23
}end: {...}
- line: 139
- column: 27
}
}- name: "cell"
}
} Text {...}
- type: "Text"
- data: " svelte-1uq0eai"
- raw: " svelte-1uq0eai"
- start: -1
- end: -1
}
]
} Attribute {...}
- type: "Attribute"
- start: 3158
- end: 3317
- name: "style"
value: [...] (9)
Text {...}
- start: 3165
- end: 3185
- type: "Text"
- raw: "\n width: "
- data: "\n width: "
} ExpressionTag {...}
- type: "ExpressionTag"
- start: 3185
- end: 3196
expression: Identifier {...}
- type: "Identifier"
- start: 3186
- end: 3195
loc: {...}
start: {...}
- line: 141
- column: 20
}end: {...}
- line: 141
- column: 29
}
}- name: "CELL_SIZE"
}
} Text {...}
- start: 3196
- end: 3220
- type: "Text"
- raw: "px;\n height: "
- data: "px;\n height: "
} ExpressionTag {...}
- type: "ExpressionTag"
- start: 3220
- end: 3231
expression: Identifier {...}
- type: "Identifier"
- start: 3221
- end: 3230
loc: {...}
start: {...}
- line: 142
- column: 21
}end: {...}
- line: 142
- column: 30
}
}- name: "CELL_SIZE"
}
} Text {...}
- start: 3231
- end: 3268
- type: "Text"
- raw: "px;\n transform: translate("
- data: "px;\n transform: translate("
} ExpressionTag {...}
- type: "ExpressionTag"
- start: 3268
- end: 3283
expression: BinaryExpression {...}
- type: "BinaryExpression"
- start: 3269
- end: 3282
loc: {...}
start: {...}
- line: 143
- column: 34
}end: {...}
- line: 143
- column: 47
}
}left: Identifier {...}
- type: "Identifier"
- start: 3269
- end: 3270
loc: {...}
start: {...}
- line: 143
- column: 34
}end: {...}
- line: 143
- column: 35
}
}- name: "x"
}- operator: "*"
right: Identifier {...}
- type: "Identifier"
- start: 3273
- end: 3282
loc: {...}
start: {...}
- line: 143
- column: 38
}end: {...}
- line: 143
- column: 47
}
}- name: "CELL_SIZE"
}
}
} Text {...}
- start: 3283
- end: 3287
- type: "Text"
- raw: "px, "
- data: "px, "
} ExpressionTag {...}
- type: "ExpressionTag"
- start: 3287
- end: 3302
expression: BinaryExpression {...}
- type: "BinaryExpression"
- start: 3288
- end: 3301
loc: {...}
start: {...}
- line: 143
- column: 53
}end: {...}
- line: 143
- column: 66
}
}left: Identifier {...}
- type: "Identifier"
- start: 3288
- end: 3289
loc: {...}
start: {...}
- line: 143
- column: 53
}end: {...}
- line: 143
- column: 54
}
}- name: "y"
}- operator: "*"
right: Identifier {...}
- type: "Identifier"
- start: 3292
- end: 3301
loc: {...}
start: {...}
- line: 143
- column: 57
}end: {...}
- line: 143
- column: 66
}
}- name: "CELL_SIZE"
}
}
} Text {...}
- start: 3302
- end: 3316
- type: "Text"
- raw: "px)\n "
- data: "px)\n "
}
]
}
]fragment: Fragment {...}
- type: "Fragment"
- nodes: []
}
} Text {...}
- type: "Text"
- start: 3333
- end: 3340
- raw: "\n "
- data: "\n "
}
]
}context: Identifier {...}
- type: "Identifier"
- name: "cell"
- start: 3095
loc: {...}
start: {...}
- line: 137
- column: 20
- character: 3095
}end: {...}
- line: 137
- column: 24
- character: 3099
}
}- end: 3099
}- index: "x"
- key: undefined
} Text {...}
- type: "Text"
- start: 3347
- end: 3352
- raw: "\n "
- data: "\n "
}
]
}context: Identifier {...}
- type: "Identifier"
- name: "row"
- start: 3067
loc: {...}
start: {...}
- line: 136
- column: 24
- character: 3067
}end: {...}
- line: 136
- column: 27
- character: 3070
}
}- end: 3070
}- index: "y"
- key: undefined
} Text {...}
- type: "Text"
- start: 3359
- end: 3362
- raw: "\n "
- data: "\n "
}
]
}
} Text {...}
- type: "Text"
- start: 3368
- end: 3372
- raw: " "
- data: " "
} IfBlock {...}
- type: "IfBlock"
- elseif: false
- start: 3372
- end: 3651
test: Identifier {...}
- type: "Identifier"
- start: 3377
- end: 3385
loc: {...}
start: {...}
- line: 150
- column: 7
}end: {...}
- line: 150
- column: 15
}
}- name: "gameOver"
}consequent: Fragment {...}
- type: "Fragment"
nodes: [...] (3)
Text {...}
- type: "Text"
- start: 3386
- end: 3391
- raw: "\n "
- data: "\n "
} RegularElement {...}
- type: "RegularElement"
- start: 3391
- end: 3539
- name: "div"
attributes: [...] (1)
Attribute {...}
- type: "Attribute"
- start: 3396
- end: 3413
- name: "class"
value: [...] (1)
Text {...}
- start: 3403
- end: 3412
- type: "Text"
- raw: "game-over"
- data: "game-over svelte-1uq0eai"
}
]
}
]fragment: Fragment {...}
- type: "Fragment"
nodes: [...] (7)
Text {...}
- type: "Text"
- start: 3414
- end: 3421
- raw: "\n "
- data: "\n "
} RegularElement {...}
- type: "RegularElement"
- start: 3421
- end: 3440
- name: "h2"
- attributes: []
fragment: Fragment {...}
- type: "Fragment"
nodes: [...] (1)
Text {...}
- type: "Text"
- start: 3425
- end: 3435
- raw: "Game Over!"
- data: "Game Over!"
}
]
}
} Text {...}
- type: "Text"
- start: 3440
- end: 3447
- raw: " "
- data: " "
} RegularElement {...}
- type: "RegularElement"
- start: 3447
- end: 3474
- name: "p"
- attributes: []
fragment: Fragment {...}
- type: "Fragment"
nodes: [...] (2)
Text {...}
- type: "Text"
- start: 3450
- end: 3463
- raw: "Final Score: "
- data: "Final Score: "
} ExpressionTag {...}
- type: "ExpressionTag"
- start: 3463
- end: 3470
expression: Identifier {...}
- type: "Identifier"
- start: 3464
- end: 3469
loc: {...}
start: {...}
- line: 153
- column: 23
}end: {...}
- line: 153
- column: 28
}
}- name: "score"
}
}
]
}
} Text {...}
- type: "Text"
- start: 3474
- end: 3481
- raw: " "
- data: " "
} RegularElement {...}
- type: "RegularElement"
- start: 3481
- end: 3528
- name: "button"
attributes: [...] (2)
Attribute {...}
- type: "Attribute"
- start: 3489
- end: 3508
- name: "onclick"
value: ExpressionTag {...}
- type: "ExpressionTag"
- start: 3497
- end: 3508
expression: Identifier {...}
- type: "Identifier"
- start: 3498
- end: 3507
loc: {...}
start: {...}
- line: 154
- column: 23
}end: {...}
- line: 154
- column: 32
}
}- name: "startGame"
}
}
} Attribute {...}
- type: "Attribute"
- start: -1
- end: -1
- name: "class"
value: [...] (1)
Text {...}
- type: "Text"
- data: "svelte-1uq0eai"
- raw: "svelte-1uq0eai"
- start: -1
- end: -1
}
]
}
]fragment: Fragment {...}
- type: "Fragment"
nodes: [...] (1)
Text {...}
- type: "Text"
- start: 3509
- end: 3519
- raw: "Play Again"
- data: "Play Again"
}
]
}
} Text {...}
- type: "Text"
- start: 3528
- end: 3533
- raw: "\n "
- data: "\n "
}
]
}
} Text {...}
- type: "Text"
- start: 3539
- end: 3542
- raw: "\n "
- data: "\n "
}
]
}alternate: Fragment {...}
- type: "Fragment"
nodes: [...] (1)
IfBlock {...}
- start: 3542
- end: 3651
- type: "IfBlock"
- elseif: true
test: UnaryExpression {...}
- type: "UnaryExpression"
- start: 3552
- end: 3569
loc: {...}
start: {...}
- line: 156
- column: 12
}end: {...}
- line: 156
- column: 29
}
}- operator: "!"
- prefix: true
argument: Identifier {...}
- type: "Identifier"
- start: 3553
- end: 3569
loc: {...}
start: {...}
- line: 156
- column: 13
}end: {...}
- line: 156
- column: 29
}
}- name: "gameLoopInterval"
}
}consequent: Fragment {...}
- type: "Fragment"
nodes: [...] (3)
Text {...}
- type: "Text"
- start: 3570
- end: 3575
- raw: "\n "
- data: "\n "
} RegularElement {...}
- type: "RegularElement"
- start: 3575
- end: 3643
- name: "button"
attributes: [...] (2)
Attribute {...}
- type: "Attribute"
- start: 3583
- end: 3603
- name: "class"
value: [...] (1)
Text {...}
- start: 3590
- end: 3602
- type: "Text"
- raw: "start-button"
- data: "start-button svelte-1uq0eai"
}
]
} Attribute {...}
- type: "Attribute"
- start: 3604
- end: 3623
- name: "onclick"
value: ExpressionTag {...}
- type: "ExpressionTag"
- start: 3612
- end: 3623
expression: Identifier {...}
- type: "Identifier"
- start: 3613
- end: 3622
loc: {...}
start: {...}
- line: 157
- column: 42
}end: {...}
- line: 157
- column: 51
}
}- name: "startGame"
}
}
}
]fragment: Fragment {...}
- type: "Fragment"
nodes: [...] (1)
Text {...}
- type: "Text"
- start: 3624
- end: 3634
- raw: "Start Game"
- data: "Start Game"
}
]
}
} Text {...}
- type: "Text"
- start: 3643
- end: 3646
- raw: "\n "
- data: "\n "
}
]
}- alternate: null
}
]
}
} Text {...}
- type: "Text"
- start: 3651
- end: 3652
- raw: "\n"
- data: "\n"
}
]
}
} Text {...}
- type: "Text"
- start: 3658
- end: 3660
- raw: "\n\n"
- data: "\n\n"
}
]
}- options: null
instance: Script {...}
- type: "Script"
- start: 0
- end: 2819
- context: "default"
content: Program {...}
- type: "Program"
- start: 18
- end: 2810
loc: {...}
start: {...}
- line: 1
- column: 0
}end: {...}
- line: 128
- column: 0
}
}body: [...] (14)
VariableDeclaration {...}
- type: "VariableDeclaration"
- start: 32
- end: 53
loc: {...}
start: {...}
- line: 3
- column: 0
}end: {...}
- line: 3
- column: 21
}
}declarations: [...] (1)
VariableDeclarator {...}
- type: "VariableDeclarator"
- start: 38
- end: 52
loc: {...}
start: {...}
- line: 3
- column: 6
}end: {...}
- line: 3
- column: 20
}
}id: Identifier {...}
- type: "Identifier"
- start: 38
- end: 47
loc: {...}
start: {...}
- line: 3
- column: 6
}end: {...}
- line: 3
- column: 15
}
}- name: "GRID_SIZE"
}init: Literal {...}
- type: "Literal"
- start: 50
- end: 52
loc: {...}
start: {...}
- line: 3
- column: 18
}end: {...}
- line: 3
- column: 20
}
}- value: 20
- raw: "20"
}
}
]- kind: "const"
leadingComments: [...] (1)
Line {...}
- type: "Line"
- value: " Grid size"
- start: 19
- end: 31
}
]
} VariableDeclaration {...}
- type: "VariableDeclaration"
- start: 54
- end: 75
loc: {...}
start: {...}
- line: 4
- column: 0
}end: {...}
- line: 4
- column: 21
}
}declarations: [...] (1)
VariableDeclarator {...}
- type: "VariableDeclarator"
- start: 60
- end: 74
loc: {...}
start: {...}
- line: 4
- column: 6
}end: {...}
- line: 4
- column: 20
}
}id: Identifier {...}
- type: "Identifier"
- start: 60
- end: 69
loc: {...}
start: {...}
- line: 4
- column: 6
}end: {...}
- line: 4
- column: 15
}
}- name: "CELL_SIZE"
}init: Literal {...}
- type: "Literal"
- start: 72
- end: 74
loc: {...}
start: {...}
- line: 4
- column: 18
}end: {...}
- line: 4
- column: 20
}
}- value: 20
- raw: "20"
}
}
]- kind: "const"
} VariableDeclaration {...}
- type: "VariableDeclaration"
- start: 91
- end: 157
loc: {...}
start: {...}
- line: 7
- column: 0
}end: {...}
- line: 7
- column: 66
}
}declarations: [...] (1)
VariableDeclarator {...}
- type: "VariableDeclarator"
- start: 95
- end: 156
loc: {...}
start: {...}
- line: 7
- column: 4
}end: {...}
- line: 7
- column: 65
}
}id: Identifier {...}
- type: "Identifier"
- start: 95
- end: 104
loc: {...}
start: {...}
- line: 7
- column: 4
}end: {...}
- line: 7
- column: 13
}
}- name: "direction"
}init: CallExpression {...}
- type: "CallExpression"
- start: 107
- end: 156
loc: {...}
start: {...}
- line: 7
- column: 16
}end: {...}
- line: 7
- column: 65
}
}callee: Identifier {...}
- type: "Identifier"
- start: 107
- end: 113
loc: {...}
start: {...}
- line: 7
- column: 16
}end: {...}
- line: 7
- column: 22
}
}- name: "$state"
}arguments: [...] (1)
Literal {...}
- type: "Literal"
- start: 148
- end: 155
loc: {...}
start: {...}
- line: 7
- column: 57
}end: {...}
- line: 7
- column: 64
}
}- value: "right"
- raw: "'right'"
}
]
}
}
]- kind: "let"
leadingComments: [...] (1)
Line {...}
- type: "Line"
- value: " Game state"
- start: 77
- end: 90
}
]
} VariableDeclaration {...}
- type: "VariableDeclaration"
- start: 158
- end: 187
loc: {...}
start: {...}
- line: 8
- column: 0
}end: {...}
- line: 8
- column: 29
}
}declarations: [...] (1)
VariableDeclarator {...}
- type: "VariableDeclarator"
- start: 162
- end: 186
loc: {...}
start: {...}
- line: 8
- column: 4
}end: {...}
- line: 8
- column: 28
}
}id: Identifier {...}
- type: "Identifier"
- start: 162
- end: 167
loc: {...}
start: {...}
- line: 8
- column: 4
}end: {...}
- line: 8
- column: 9
}
}- name: "snake"
}init: CallExpression {...}
- type: "CallExpression"
- start: 170
- end: 186
loc: {...}
start: {...}
- line: 8
- column: 12
}end: {...}
- line: 8
- column: 28
}
}callee: Identifier {...}
- type: "Identifier"
- start: 170
- end: 176
loc: {...}
start: {...}
- line: 8
- column: 12
}end: {...}
- line: 8
- column: 18
}
}- name: "$state"
}arguments: [...] (1)
ArrayExpression {...}
- type: "ArrayExpression"
- start: 177
- end: 185
loc: {...}
start: {...}
- line: 8
- column: 19
}end: {...}
- line: 8
- column: 27
}
}elements: [...] (1)
ArrayExpression {...}
- type: "ArrayExpression"
- start: 178
- end: 184
loc: {...}
start: {...}
- line: 8
- column: 20
}end: {...}
- line: 8
- column: 26
}
}elements: [...] (2)
Literal {...}
- type: "Literal"
- start: 179
- end: 180
loc: {...}
start: {...}
- line: 8
- column: 21
}end: {...}
- line: 8
- column: 22
}
}- value: 0
- raw: "0"
} Literal {...}
- type: "Literal"
- start: 182
- end: 183
loc: {...}
start: {...}
- line: 8
- column: 24
}end: {...}
- line: 8
- column: 25
}
}- value: 0
- raw: "0"
}
]
}
]
}
]- optional: false
}
}
]- kind: "let"
trailingComments: [...] (1)
Line {...}
- type: "Line"
- value: " Array of [x, y] coordinates"
- start: 188
- end: 218
}
]
} VariableDeclaration {...}
- type: "VariableDeclaration"
- start: 219
- end: 263
loc: {...}
start: {...}
- line: 9
- column: 0
}end: {...}
- line: 9
- column: 44
}
}declarations: [...] (1)
VariableDeclarator {...}
- type: "VariableDeclarator"
- start: 223
- end: 262
loc: {...}
start: {...}
- line: 9
- column: 4
}end: {...}
- line: 9
- column: 43
}
}id: Identifier {...}
- type: "Identifier"
- start: 223
- end: 227
loc: {...}
start: {...}
- line: 9
- column: 4
}end: {...}
- line: 9
- column: 8
}
}- name: "food"
}init: CallExpression {...}
- type: "CallExpression"
- start: 230
- end: 262
loc: {...}
start: {...}
- line: 9
- column: 11
}end: {...}
- line: 9
- column: 43
}
}callee: Identifier {...}
- type: "Identifier"
- start: 230
- end: 236
loc: {...}
start: {...}
- line: 9
- column: 11
}end: {...}
- line: 9
- column: 17
}
}- name: "$state"
}arguments: [...] (1)
ArrayExpression {...}
- type: "ArrayExpression"
- start: 255
- end: 261
loc: {...}
start: {...}
- line: 9
- column: 36
}end: {...}
- line: 9
- column: 42
}
}elements: [...] (2)
Literal {...}
- type: "Literal"
- start: 256
- end: 257
loc: {...}
start: {...}
- line: 9
- column: 37
}end: {...}
- line: 9
- column: 38
}
}- value: 5
- raw: "5"
} Literal {...}
- type: "Literal"
- start: 259
- end: 260
loc: {...}
start: {...}
- line: 9
- column: 40
}end: {...}
- line: 9
- column: 41
}
}- value: 5
- raw: "5"
}
]
}
]
}
}
]- kind: "let"
} VariableDeclaration {...}
- type: "VariableDeclaration"
- start: 264
- end: 286
loc: {...}
start: {...}
- line: 10
- column: 0
}end: {...}
- line: 10
- column: 22
}
}declarations: [...] (1)
VariableDeclarator {...}
- type: "VariableDeclarator"
- start: 268
- end: 285
loc: {...}
start: {...}
- line: 10
- column: 4
}end: {...}
- line: 10
- column: 21
}
}id: Identifier {...}
- type: "Identifier"
- start: 268
- end: 273
loc: {...}
start: {...}
- line: 10
- column: 4
}end: {...}
- line: 10
- column: 9
}
}- name: "score"
}init: CallExpression {...}
- type: "CallExpression"
- start: 276
- end: 285
loc: {...}
start: {...}
- line: 10
- column: 12
}end: {...}
- line: 10
- column: 21
}
}callee: Identifier {...}
- type: "Identifier"
- start: 276
- end: 282
loc: {...}
start: {...}
- line: 10
- column: 12
}end: {...}
- line: 10
- column: 18
}
}- name: "$state"
}arguments: [...] (1)
Literal {...}
- type: "Literal"
- start: 283
- end: 284
loc: {...}
start: {...}
- line: 10
- column: 19
}end: {...}
- line: 10
- column: 20
}
}- value: 0
- raw: "0"
}
]- optional: false
}
}
]- kind: "let"
} VariableDeclaration {...}
- type: "VariableDeclaration"
- start: 287
- end: 316
loc: {...}
start: {...}
- line: 11
- column: 0
}end: {...}
- line: 11
- column: 29
}
}declarations: [...] (1)
VariableDeclarator {...}
- type: "VariableDeclarator"
- start: 291
- end: 315
loc: {...}
start: {...}
- line: 11
- column: 4
}end: {...}
- line: 11
- column: 28
}
}id: Identifier {...}
- type: "Identifier"
- start: 291
- end: 299
loc: {...}
start: {...}
- line: 11
- column: 4
}end: {...}
- line: 11
- column: 12
}
}- name: "gameOver"
}init: CallExpression {...}
- type: "CallExpression"
- start: 302
- end: 315
loc: {...}
start: {...}
- line: 11
- column: 15
}end: {...}
- line: 11
- column: 28
}
}callee: Identifier {...}
- type: "Identifier"
- start: 302
- end: 308
loc: {...}
start: {...}
- line: 11
- column: 15
}end: {...}
- line: 11
- column: 21
}
}- name: "$state"
}arguments: [...] (1)
Literal {...}
- type: "Literal"
- start: 309
- end: 314
loc: {...}
start: {...}
- line: 11
- column: 22
}end: {...}
- line: 11
- column: 27
}
}- value: false
- raw: "false"
}
]- optional: false
}
}
]- kind: "let"
} VariableDeclaration {...}
- type: "VariableDeclaration"
- start: 317
- end: 368
loc: {...}
start: {...}
- line: 12
- column: 0
}end: {...}
- line: 12
- column: 51
}
}declarations: [...] (1)
VariableDeclarator {...}
- type: "VariableDeclarator"
- start: 321
- end: 367
loc: {...}
start: {...}
- line: 12
- column: 4
}end: {...}
- line: 12
- column: 50
}
}id: Identifier {...}
- type: "Identifier"
- start: 321
- end: 337
loc: {...}
start: {...}
- line: 12
- column: 4
}end: {...}
- line: 12
- column: 20
}
}- name: "gameLoopInterval"
}init: CallExpression {...}
- type: "CallExpression"
- start: 340
- end: 367
loc: {...}
start: {...}
- line: 12
- column: 23
}end: {...}
- line: 12
- column: 50
}
}callee: Identifier {...}
- type: "Identifier"
- start: 340
- end: 346
loc: {...}
start: {...}
- line: 12
- column: 23
}end: {...}
- line: 12
- column: 29
}
}- name: "$state"
}arguments: [...] (1)
Literal {...}
- type: "Literal"
- start: 362
- end: 366
loc: {...}
start: {...}
- line: 12
- column: 45
}end: {...}
- line: 12
- column: 49
}
}- value: null
- raw: "null"
}
]
}
}
]- kind: "let"
} VariableDeclaration {...}
- type: "VariableDeclaration"
- start: 388
- end: 782
loc: {...}
start: {...}
- line: 15
- column: 0
}end: {...}
- line: 31
- column: 3
}
}declarations: [...] (1)
VariableDeclarator {...}
- type: "VariableDeclarator"
- start: 392
- end: 781
loc: {...}
start: {...}
- line: 15
- column: 4
}end: {...}
- line: 31
- column: 2
}
}id: Identifier {...}
- type: "Identifier"
- start: 392
- end: 401
loc: {...}
start: {...}
- line: 15
- column: 4
}end: {...}
- line: 15
- column: 13
}
}- name: "gameBoard"
}init: CallExpression {...}
- type: "CallExpression"
- start: 404
- end: 781
loc: {...}
start: {...}
- line: 15
- column: 16
}end: {...}
- line: 31
- column: 2
}
}callee: MemberExpression {...}
- type: "MemberExpression"
- start: 404
- end: 415
loc: {...}
start: {...}
- line: 15
- column: 16
}end: {...}
- line: 15
- column: 27
}
}object: Identifier {...}
- type: "Identifier"
- start: 404
- end: 412
loc: {...}
start: {...}
- line: 15
- column: 16
}end: {...}
- line: 15
- column: 24
}
}- name: "$derived"
}property: Identifier {...}
- type: "Identifier"
- start: 413
- end: 415
loc: {...}
start: {...}
- line: 15
- column: 25
}end: {...}
- line: 15
- column: 27
}
}- name: "by"
}- computed: false
- optional: false
}arguments: [...] (1)
ArrowFunctionExpression {...}
- type: "ArrowFunctionExpression"
- start: 416
- end: 780
loc: {...}
start: {...}
- line: 15
- column: 28
}end: {...}
- line: 31
- column: 1
}
}- id: null
- expression: false
- generator: false
- async: false
- params: []
body: BlockStatement {...}
- type: "BlockStatement"
- start: 422
- end: 780
loc: {...}
start: {...}
- line: 15
- column: 34
}end: {...}
- line: 31
- column: 1
}
}body: [...] (4)
VariableDeclaration {...}
- type: "VariableDeclaration"
- start: 426
- end: 557
loc: {...}
start: {...}
- line: 16
- column: 2
}end: {...}
- line: 18
- column: 47
}
}declarations: [...] (1)
VariableDeclarator {...}
- type: "VariableDeclarator"
- start: 432
- end: 556
loc: {...}
start: {...}
- line: 16
- column: 8
}end: {...}
- line: 18
- column: 46
}
}id: Identifier {...}
- type: "Identifier"
- start: 432
- end: 437
loc: {...}
start: {...}
- line: 16
- column: 8
}end: {...}
- line: 16
- column: 47
}
}- name: "board"
}init: CallExpression {...}
- type: "CallExpression"
- start: 474
- end: 556
loc: {...}
start: {...}
- line: 16
- column: 50
}end: {...}
- line: 18
- column: 46
}
}callee: MemberExpression {...}
- type: "MemberExpression"
- start: 474
- end: 518
loc: {...}
start: {...}
- line: 16
- column: 50
}end: {...}
- line: 18
- column: 8
}
}object: CallExpression {...}
- type: "CallExpression"
- start: 474
- end: 509
loc: {...}
start: {...}
- line: 16
- column: 50
}end: {...}
- line: 17
- column: 18
}
}callee: MemberExpression {...}
- type: "MemberExpression"
- start: 474
- end: 500
loc: {...}
start: {...}
- line: 16
- column: 50
}end: {...}
- line: 17
- column: 9
}
}object: CallExpression {...}
- type: "CallExpression"
- start: 474
- end: 490
loc: {...}
start: {...}
- line: 16
- column: 50
}end: {...}
- line: 16
- column: 66
}
}callee: Identifier {...}
- type: "Identifier"
- start: 474
- end: 479
loc: {...}
start: {...}
- line: 16
- column: 50
}end: {...}
- line: 16
- column: 55
}
}- name: "Array"
}arguments: [...] (1)
Identifier {...}
- type: "Identifier"
- start: 480
- end: 489
loc: {...}
start: {...}
- line: 16
- column: 56
}end: {...}
- line: 16
- column: 65
}
}- name: "GRID_SIZE"
}
]- optional: false
}property: Identifier {...}
- type: "Identifier"
- start: 496
- end: 500
loc: {...}
start: {...}
- line: 17
- column: 5
}end: {...}
- line: 17
- column: 9
}
}- name: "fill"
}- computed: false
- optional: false
}arguments: [...] (1)
Literal {...}
- type: "Literal"
- start: 501
- end: 508
loc: {...}
start: {...}
- line: 17
- column: 10
}end: {...}
- line: 17
- column: 17
}
}- value: "empty"
- raw: "'empty'"
}
]- optional: false
}property: Identifier {...}
- type: "Identifier"
- start: 515
- end: 518
loc: {...}
start: {...}
- line: 18
- column: 5
}end: {...}
- line: 18
- column: 8
}
}- name: "map"
}- computed: false
- optional: false
}arguments: [...] (1)
ArrowFunctionExpression {...}
- type: "ArrowFunctionExpression"
- start: 519
- end: 555
loc: {...}
start: {...}
- line: 18
- column: 9
}end: {...}
- line: 18
- column: 45
}
}- id: null
- expression: true
- generator: false
- async: false
- params: []
body: CallExpression {...}
- type: "CallExpression"
- start: 525
- end: 555
loc: {...}
start: {...}
- line: 18
- column: 15
}end: {...}
- line: 18
- column: 45
}
}callee: MemberExpression {...}
- type: "MemberExpression"
- start: 525
- end: 546
loc: {...}
start: {...}
- line: 18
- column: 15
}end: {...}
- line: 18
- column: 36
}
}object: CallExpression {...}
- type: "CallExpression"
- start: 525
- end: 541
loc: {...}
start: {...}
- line: 18
- column: 15
}end: {...}
- line: 18
- column: 31
}
}callee: Identifier {...}
- type: "Identifier"
- start: 525
- end: 530
loc: {...}
start: {...}
- line: 18
- column: 15
}end: {...}
- line: 18
- column: 20
}
}- name: "Array"
}arguments: [...] (1)
Identifier {...}
- type: "Identifier"
- start: 531
- end: 540
loc: {...}
start: {...}
- line: 18
- column: 21
}end: {...}
- line: 18
- column: 30
}
}- name: "GRID_SIZE"
}
]- optional: false
}property: Identifier {...}
- type: "Identifier"
- start: 542
- end: 546
loc: {...}
start: {...}
- line: 18
- column: 32
}end: {...}
- line: 18
- column: 36
}
}- name: "fill"
}- computed: false
- optional: false
}arguments: [...] (1)
Literal {...}
- type: "Literal"
- start: 547
- end: 554
loc: {...}
start: {...}
- line: 18
- column: 37
}end: {...}
- line: 18
- column: 44
}
}- value: "empty"
- raw: "'empty'"
}
]- optional: false
}
}
]- optional: false
}
}
]- kind: "const"
} ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 578
- end: 708
loc: {...}
start: {...}
- line: 21
- column: 2
}end: {...}
- line: 25
- column: 5
}
}expression: CallExpression {...}
- type: "CallExpression"
- start: 578
- end: 707
loc: {...}
start: {...}
- line: 21
- column: 2
}end: {...}
- line: 25
- column: 4
}
}callee: MemberExpression {...}
- type: "MemberExpression"
- start: 578
- end: 591
loc: {...}
start: {...}
- line: 21
- column: 2
}end: {...}
- line: 21
- column: 15
}
}object: Identifier {...}
- type: "Identifier"
- start: 578
- end: 583
loc: {...}
start: {...}
- line: 21
- column: 2
}end: {...}
- line: 21
- column: 7
}
}- name: "snake"
}property: Identifier {...}
- type: "Identifier"
- start: 584
- end: 591
loc: {...}
start: {...}
- line: 21
- column: 8
}end: {...}
- line: 21
- column: 15
}
}- name: "forEach"
}- computed: false
- optional: false
}arguments: [...] (1)
ArrowFunctionExpression {...}
- type: "ArrowFunctionExpression"
- start: 592
- end: 706
loc: {...}
start: {...}
- line: 21
- column: 16
}end: {...}
- line: 25
- column: 3
}
}- id: null
- expression: false
- generator: false
- async: false
params: [...] (1)
ArrayPattern {...}
- type: "ArrayPattern"
- start: 593
- end: 599
loc: {...}
start: {...}
- line: 21
- column: 17
}end: {...}
- line: 21
- column: 23
}
}elements: [...] (2)
Identifier {...}
- type: "Identifier"
- start: 594
- end: 595
loc: {...}
start: {...}
- line: 21
- column: 18
}end: {...}
- line: 21
- column: 19
}
}- name: "x"
} Identifier {...}
- type: "Identifier"
- start: 597
- end: 598
loc: {...}
start: {...}
- line: 21
- column: 21
}end: {...}
- line: 21
- column: 22
}
}- name: "y"
}
]
}
]body: BlockStatement {...}
- type: "BlockStatement"
- start: 604
- end: 706
loc: {...}
start: {...}
- line: 21
- column: 28
}end: {...}
- line: 25
- column: 3
}
}body: [...] (1)
IfStatement {...}
- type: "IfStatement"
- start: 610
- end: 702
loc: {...}
start: {...}
- line: 22
- column: 4
}end: {...}
- line: 24
- column: 5
}
}test: LogicalExpression {...}
- type: "LogicalExpression"
- start: 614
- end: 664
loc: {...}
start: {...}
- line: 22
- column: 8
}end: {...}
- line: 22
- column: 58
}
}left: LogicalExpression {...}
- type: "LogicalExpression"
- start: 614
- end: 647
loc: {...}
start: {...}
- line: 22
- column: 8
}end: {...}
- line: 22
- column: 41
}
}left: LogicalExpression {...}
- type: "LogicalExpression"
- start: 614
- end: 637
loc: {...}
start: {...}
- line: 22
- column: 8
}end: {...}
- line: 22
- column: 31
}
}left: BinaryExpression {...}
- type: "BinaryExpression"
- start: 614
- end: 620
loc: {...}
start: {...}
- line: 22
- column: 8
}end: {...}
- line: 22
- column: 14
}
}left: Identifier {...}
- type: "Identifier"
- start: 614
- end: 615
loc: {...}
start: {...}
- line: 22
- column: 8
}end: {...}
- line: 22
- column: 9
}
}- name: "x"
}- operator: ">="
right: Literal {...}
- type: "Literal"
- start: 619
- end: 620
loc: {...}
start: {...}
- line: 22
- column: 13
}end: {...}
- line: 22
- column: 14
}
}- value: 0
- raw: "0"
}
}- operator: "&&"
right: BinaryExpression {...}
- type: "BinaryExpression"
- start: 624
- end: 637
loc: {...}
start: {...}
- line: 22
- column: 18
}end: {...}
- line: 22
- column: 31
}
}left: Identifier {...}
- type: "Identifier"
- start: 624
- end: 625
loc: {...}
start: {...}
- line: 22
- column: 18
}end: {...}
- line: 22
- column: 19
}
}- name: "x"
}- operator: "<"
right: Identifier {...}
- type: "Identifier"
- start: 628
- end: 637
loc: {...}
start: {...}
- line: 22
- column: 22
}end: {...}
- line: 22
- column: 31
}
}- name: "GRID_SIZE"
}
}
}- operator: "&&"
right: BinaryExpression {...}
- type: "BinaryExpression"
- start: 641
- end: 647
loc: {...}
start: {...}
- line: 22
- column: 35
}end: {...}
- line: 22
- column: 41
}
}left: Identifier {...}
- type: "Identifier"
- start: 641
- end: 642
loc: {...}
start: {...}
- line: 22
- column: 35
}end: {...}
- line: 22
- column: 36
}
}- name: "y"
}- operator: ">="
right: Literal {...}
- type: "Literal"
- start: 646
- end: 647
loc: {...}
start: {...}
- line: 22
- column: 40
}end: {...}
- line: 22
- column: 41
}
}- value: 0
- raw: "0"
}
}
}- operator: "&&"
right: BinaryExpression {...}
- type: "BinaryExpression"
- start: 651
- end: 664
loc: {...}
start: {...}
- line: 22
- column: 45
}end: {...}
- line: 22
- column: 58
}
}left: Identifier {...}
- type: "Identifier"
- start: 651
- end: 652
loc: {...}
start: {...}
- line: 22
- column: 45
}end: {...}
- line: 22
- column: 46
}
}- name: "y"
}- operator: "<"
right: Identifier {...}
- type: "Identifier"
- start: 655
- end: 664
loc: {...}
start: {...}
- line: 22
- column: 49
}end: {...}
- line: 22
- column: 58
}
}- name: "GRID_SIZE"
}
}
}consequent: BlockStatement {...}
- type: "BlockStatement"
- start: 666
- end: 702
loc: {...}
start: {...}
- line: 22
- column: 60
}end: {...}
- line: 24
- column: 5
}
}body: [...] (1)
ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 674
- end: 696
loc: {...}
start: {...}
- line: 23
- column: 6
}end: {...}
- line: 23
- column: 28
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 674
- end: 695
loc: {...}
start: {...}
- line: 23
- column: 6
}end: {...}
- line: 23
- column: 27
}
}- operator: "="
left: MemberExpression {...}
- type: "MemberExpression"
- start: 674
- end: 685
loc: {...}
start: {...}
- line: 23
- column: 6
}end: {...}
- line: 23
- column: 17
}
}object: MemberExpression {...}
- type: "MemberExpression"
- start: 674
- end: 682
loc: {...}
start: {...}
- line: 23
- column: 6
}end: {...}
- line: 23
- column: 14
}
}object: Identifier {...}
- type: "Identifier"
- start: 674
- end: 679
loc: {...}
start: {...}
- line: 23
- column: 6
}end: {...}
- line: 23
- column: 11
}
}- name: "board"
}property: Identifier {...}
- type: "Identifier"
- start: 680
- end: 681
loc: {...}
start: {...}
- line: 23
- column: 12
}end: {...}
- line: 23
- column: 13
}
}- name: "y"
}- computed: true
- optional: false
}property: Identifier {...}
- type: "Identifier"
- start: 683
- end: 684
loc: {...}
start: {...}
- line: 23
- column: 15
}end: {...}
- line: 23
- column: 16
}
}- name: "x"
}- computed: true
- optional: false
}right: Literal {...}
- type: "Literal"
- start: 688
- end: 695
loc: {...}
start: {...}
- line: 23
- column: 20
}end: {...}
- line: 23
- column: 27
}
}- value: "snake"
- raw: "'snake'"
}
}
}
]
}- alternate: null
}
]
}
}
]- optional: false
}leadingComments: [...] (1)
Line {...}
- type: "Line"
- value: " Place snake"
- start: 561
- end: 575
}
]
} ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 728
- end: 761
loc: {...}
start: {...}
- line: 28
- column: 2
}end: {...}
- line: 28
- column: 35
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 728
- end: 760
loc: {...}
start: {...}
- line: 28
- column: 2
}end: {...}
- line: 28
- column: 34
}
}- operator: "="
left: MemberExpression {...}
- type: "MemberExpression"
- start: 728
- end: 751
loc: {...}
start: {...}
- line: 28
- column: 2
}end: {...}
- line: 28
- column: 25
}
}object: MemberExpression {...}
- type: "MemberExpression"
- start: 728
- end: 742
loc: {...}
start: {...}
- line: 28
- column: 2
}end: {...}
- line: 28
- column: 16
}
}object: Identifier {...}
- type: "Identifier"
- start: 728
- end: 733
loc: {...}
start: {...}
- line: 28
- column: 2
}end: {...}
- line: 28
- column: 7
}
}- name: "board"
}property: MemberExpression {...}
- type: "MemberExpression"
- start: 734
- end: 741
loc: {...}
start: {...}
- line: 28
- column: 8
}end: {...}
- line: 28
- column: 15
}
}object: Identifier {...}
- type: "Identifier"
- start: 734
- end: 738
loc: {...}
start: {...}
- line: 28
- column: 8
}end: {...}
- line: 28
- column: 12
}
}- name: "food"
}property: Literal {...}
- type: "Literal"
- start: 739
- end: 740
loc: {...}
start: {...}
- line: 28
- column: 13
}end: {...}
- line: 28
- column: 14
}
}- value: 1
- raw: "1"
}- computed: true
- optional: false
}- computed: true
- optional: false
}property: MemberExpression {...}
- type: "MemberExpression"
- start: 743
- end: 750
loc: {...}
start: {...}
- line: 28
- column: 17
}end: {...}
- line: 28
- column: 24
}
}object: Identifier {...}
- type: "Identifier"
- start: 743
- end: 747
loc: {...}
start: {...}
- line: 28
- column: 17
}end: {...}
- line: 28
- column: 21
}
}- name: "food"
}property: Literal {...}
- type: "Literal"
- start: 748
- end: 749
loc: {...}
start: {...}
- line: 28
- column: 22
}end: {...}
- line: 28
- column: 23
}
}- value: 0
- raw: "0"
}- computed: true
- optional: false
}- computed: true
- optional: false
}right: Literal {...}
- type: "Literal"
- start: 754
- end: 760
loc: {...}
start: {...}
- line: 28
- column: 28
}end: {...}
- line: 28
- column: 34
}
}- value: "food"
- raw: "'food'"
}
}leadingComments: [...] (1)
Line {...}
- type: "Line"
- value: " Place food"
- start: 712
- end: 725
}
]
} ReturnStatement {...}
- type: "ReturnStatement"
- start: 765
- end: 778
loc: {...}
start: {...}
- line: 30
- column: 2
}end: {...}
- line: 30
- column: 15
}
}argument: Identifier {...}
- type: "Identifier"
- start: 772
- end: 777
loc: {...}
start: {...}
- line: 30
- column: 9
}end: {...}
- line: 30
- column: 14
}
}- name: "board"
}
}
]
}
}
]- optional: false
}
}
]- kind: "let"
leadingComments: [...] (1)
Line {...}
- type: "Line"
- value: " Derived values"
- start: 370
- end: 387
}
]
} FunctionDeclaration {...}
- type: "FunctionDeclaration"
- start: 808
- end: 938
loc: {...}
start: {...}
- line: 34
- column: 0
}end: {...}
- line: 39
- column: 1
}
}id: Identifier {...}
- type: "Identifier"
- start: 817
- end: 826
loc: {...}
start: {...}
- line: 34
- column: 9
}end: {...}
- line: 34
- column: 18
}
}- name: "startGame"
}- expression: false
- generator: false
- async: false
- params: []
body: BlockStatement {...}
- type: "BlockStatement"
- start: 829
- end: 938
loc: {...}
start: {...}
- line: 34
- column: 21
}end: {...}
- line: 39
- column: 1
}
}body: [...] (3)
IfStatement {...}
- type: "IfStatement"
- start: 833
- end: 862
loc: {...}
start: {...}
- line: 35
- column: 2
}end: {...}
- line: 35
- column: 31
}
}test: Identifier {...}
- type: "Identifier"
- start: 837
- end: 853
loc: {...}
start: {...}
- line: 35
- column: 6
}end: {...}
- line: 35
- column: 22
}
}- name: "gameLoopInterval"
}consequent: ReturnStatement {...}
- type: "ReturnStatement"
- start: 855
- end: 862
loc: {...}
start: {...}
- line: 35
- column: 24
}end: {...}
- line: 35
- column: 31
}
}- argument: null
}- alternate: null
} ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 868
- end: 880
loc: {...}
start: {...}
- line: 37
- column: 2
}end: {...}
- line: 37
- column: 14
}
}expression: CallExpression {...}
- type: "CallExpression"
- start: 868
- end: 879
loc: {...}
start: {...}
- line: 37
- column: 2
}end: {...}
- line: 37
- column: 13
}
}callee: Identifier {...}
- type: "Identifier"
- start: 868
- end: 877
loc: {...}
start: {...}
- line: 37
- column: 2
}end: {...}
- line: 37
- column: 11
}
}- name: "resetGame"
}- arguments: []
- optional: false
}
} ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 883
- end: 936
loc: {...}
start: {...}
- line: 38
- column: 2
}end: {...}
- line: 38
- column: 55
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 883
- end: 935
loc: {...}
start: {...}
- line: 38
- column: 2
}end: {...}
- line: 38
- column: 54
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 883
- end: 899
loc: {...}
start: {...}
- line: 38
- column: 2
}end: {...}
- line: 38
- column: 18
}
}- name: "gameLoopInterval"
}right: CallExpression {...}
- type: "CallExpression"
- start: 902
- end: 935
loc: {...}
start: {...}
- line: 38
- column: 21
}end: {...}
- line: 38
- column: 54
}
}callee: MemberExpression {...}
- type: "MemberExpression"
- start: 902
- end: 920
loc: {...}
start: {...}
- line: 38
- column: 21
}end: {...}
- line: 38
- column: 39
}
}object: Identifier {...}
- type: "Identifier"
- start: 902
- end: 908
loc: {...}
start: {...}
- line: 38
- column: 21
}end: {...}
- line: 38
- column: 27
}
}- name: "window"
}property: Identifier {...}
- type: "Identifier"
- start: 909
- end: 920
loc: {...}
start: {...}
- line: 38
- column: 28
}end: {...}
- line: 38
- column: 39
}
}- name: "setInterval"
}- computed: false
- optional: false
}arguments: [...] (2)
Identifier {...}
- type: "Identifier"
- start: 921
- end: 929
loc: {...}
start: {...}
- line: 38
- column: 40
}end: {...}
- line: 38
- column: 48
}
}- name: "gameLoop"
} Literal {...}
- type: "Literal"
- start: 931
- end: 934
loc: {...}
start: {...}
- line: 38
- column: 50
}end: {...}
- line: 38
- column: 53
}
}- value: 150
- raw: "150"
}
]- optional: false
}
}
}
]
}leadingComments: [...] (1)
Line {...}
- type: "Line"
- value: " Game logic functions"
- start: 784
- end: 807
}
]
} FunctionDeclaration {...}
- type: "FunctionDeclaration"
- start: 940
- end: 1055
loc: {...}
start: {...}
- line: 41
- column: 0
}end: {...}
- line: 47
- column: 1
}
}id: Identifier {...}
- type: "Identifier"
- start: 949
- end: 958
loc: {...}
start: {...}
- line: 41
- column: 9
}end: {...}
- line: 41
- column: 18
}
}- name: "resetGame"
}- expression: false
- generator: false
- async: false
- params: []
body: BlockStatement {...}
- type: "BlockStatement"
- start: 961
- end: 1055
loc: {...}
start: {...}
- line: 41
- column: 21
}end: {...}
- line: 47
- column: 1
}
}body: [...] (5)
ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 965
- end: 982
loc: {...}
start: {...}
- line: 42
- column: 2
}end: {...}
- line: 42
- column: 19
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 965
- end: 981
loc: {...}
start: {...}
- line: 42
- column: 2
}end: {...}
- line: 42
- column: 18
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 965
- end: 970
loc: {...}
start: {...}
- line: 42
- column: 2
}end: {...}
- line: 42
- column: 7
}
}- name: "snake"
}right: ArrayExpression {...}
- type: "ArrayExpression"
- start: 973
- end: 981
loc: {...}
start: {...}
- line: 42
- column: 10
}end: {...}
- line: 42
- column: 18
}
}elements: [...] (1)
ArrayExpression {...}
- type: "ArrayExpression"
- start: 974
- end: 980
loc: {...}
start: {...}
- line: 42
- column: 11
}end: {...}
- line: 42
- column: 17
}
}elements: [...] (2)
Literal {...}
- type: "Literal"
- start: 975
- end: 976
loc: {...}
start: {...}
- line: 42
- column: 12
}end: {...}
- line: 42
- column: 13
}
}- value: 0
- raw: "0"
} Literal {...}
- type: "Literal"
- start: 978
- end: 979
loc: {...}
start: {...}
- line: 42
- column: 15
}end: {...}
- line: 42
- column: 16
}
}- value: 0
- raw: "0"
}
]
}
]
}
}
} ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 985
- end: 1005
loc: {...}
start: {...}
- line: 43
- column: 2
}end: {...}
- line: 43
- column: 22
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 985
- end: 1004
loc: {...}
start: {...}
- line: 43
- column: 2
}end: {...}
- line: 43
- column: 21
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 985
- end: 994
loc: {...}
start: {...}
- line: 43
- column: 2
}end: {...}
- line: 43
- column: 11
}
}- name: "direction"
}right: Literal {...}
- type: "Literal"
- start: 997
- end: 1004
loc: {...}
start: {...}
- line: 43
- column: 14
}end: {...}
- line: 43
- column: 21
}
}- value: "right"
- raw: "'right'"
}
}
} ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 1008
- end: 1018
loc: {...}
start: {...}
- line: 44
- column: 2
}end: {...}
- line: 44
- column: 12
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 1008
- end: 1017
loc: {...}
start: {...}
- line: 44
- column: 2
}end: {...}
- line: 44
- column: 11
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 1008
- end: 1013
loc: {...}
start: {...}
- line: 44
- column: 2
}end: {...}
- line: 44
- column: 7
}
}- name: "score"
}right: Literal {...}
- type: "Literal"
- start: 1016
- end: 1017
loc: {...}
start: {...}
- line: 44
- column: 10
}end: {...}
- line: 44
- column: 11
}
}- value: 0
- raw: "0"
}
}
} ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 1021
- end: 1038
loc: {...}
start: {...}
- line: 45
- column: 2
}end: {...}
- line: 45
- column: 19
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 1021
- end: 1037
loc: {...}
start: {...}
- line: 45
- column: 2
}end: {...}
- line: 45
- column: 18
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 1021
- end: 1029
loc: {...}
start: {...}
- line: 45
- column: 2
}end: {...}
- line: 45
- column: 10
}
}- name: "gameOver"
}right: Literal {...}
- type: "Literal"
- start: 1032
- end: 1037
loc: {...}
start: {...}
- line: 45
- column: 13
}end: {...}
- line: 45
- column: 18
}
}- value: false
- raw: "false"
}
}
} ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 1041
- end: 1053
loc: {...}
start: {...}
- line: 46
- column: 2
}end: {...}
- line: 46
- column: 14
}
}expression: CallExpression {...}
- type: "CallExpression"
- start: 1041
- end: 1052
loc: {...}
start: {...}
- line: 46
- column: 2
}end: {...}
- line: 46
- column: 13
}
}callee: Identifier {...}
- type: "Identifier"
- start: 1041
- end: 1050
loc: {...}
start: {...}
- line: 46
- column: 2
}end: {...}
- line: 46
- column: 11
}
}- name: "placeFood"
}- arguments: []
- optional: false
}
}
]
}
} FunctionDeclaration {...}
- type: "FunctionDeclaration"
- start: 1057
- end: 1328
loc: {...}
start: {...}
- line: 49
- column: 0
}end: {...}
- line: 59
- column: 1
}
}id: Identifier {...}
- type: "Identifier"
- start: 1066
- end: 1075
loc: {...}
start: {...}
- line: 49
- column: 9
}end: {...}
- line: 49
- column: 18
}
}- name: "placeFood"
}- expression: false
- generator: false
- async: false
- params: []
body: BlockStatement {...}
- type: "BlockStatement"
- start: 1078
- end: 1328
loc: {...}
start: {...}
- line: 49
- column: 21
}end: {...}
- line: 59
- column: 1
}
}body: [...] (3)
VariableDeclaration {...}
- type: "VariableDeclaration"
- start: 1082
- end: 1112
loc: {...}
start: {...}
- line: 50
- column: 2
}end: {...}
- line: 50
- column: 32
}
}declarations: [...] (1)
VariableDeclarator {...}
- type: "VariableDeclarator"
- start: 1086
- end: 1111
loc: {...}
start: {...}
- line: 50
- column: 6
}end: {...}
- line: 50
- column: 31
}
}id: Identifier {...}
- type: "Identifier"
- start: 1086
- end: 1093
loc: {...}
start: {...}
- line: 50
- column: 6
}end: {...}
- line: 50
- column: 31
}
}- name: "newFood"
}- init: null
}
]- kind: "let"
} DoWhileStatement {...}
- type: "DoWhileStatement"
- start: 1115
- end: 1305
loc: {...}
start: {...}
- line: 51
- column: 2
}end: {...}
- line: 56
- column: 73
}
}body: BlockStatement {...}
- type: "BlockStatement"
- start: 1118
- end: 1235
loc: {...}
start: {...}
- line: 51
- column: 5
}end: {...}
- line: 56
- column: 3
}
}body: [...] (1)
ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 1124
- end: 1231
loc: {...}
start: {...}
- line: 52
- column: 4
}end: {...}
- line: 55
- column: 6
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 1124
- end: 1230
loc: {...}
start: {...}
- line: 52
- column: 4
}end: {...}
- line: 55
- column: 5
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 1124
- end: 1131
loc: {...}
start: {...}
- line: 52
- column: 4
}end: {...}
- line: 52
- column: 11
}
}- name: "newFood"
}right: ArrayExpression {...}
- type: "ArrayExpression"
- start: 1134
- end: 1230
loc: {...}
start: {...}
- line: 52
- column: 14
}end: {...}
- line: 55
- column: 5
}
}elements: [...] (2)
CallExpression {...}
- type: "CallExpression"
- start: 1142
- end: 1179
loc: {...}
start: {...}
- line: 53
- column: 6
}end: {...}
- line: 53
- column: 43
}
}callee: MemberExpression {...}
- type: "MemberExpression"
- start: 1142
- end: 1152
loc: {...}
start: {...}
- line: 53
- column: 6
}end: {...}
- line: 53
- column: 16
}
}object: Identifier {...}
- type: "Identifier"
- start: 1142
- end: 1146
loc: {...}
start: {...}
- line: 53
- column: 6
}end: {...}
- line: 53
- column: 10
}
}- name: "Math"
}property: Identifier {...}
- type: "Identifier"
- start: 1147
- end: 1152
loc: {...}
start: {...}
- line: 53
- column: 11
}end: {...}
- line: 53
- column: 16
}
}- name: "floor"
}- computed: false
- optional: false
}arguments: [...] (1)
BinaryExpression {...}
- type: "BinaryExpression"
- start: 1153
- end: 1178
loc: {...}
start: {...}
- line: 53
- column: 17
}end: {...}
- line: 53
- column: 42
}
}left: CallExpression {...}
- type: "CallExpression"
- start: 1153
- end: 1166
loc: {...}
start: {...}
- line: 53
- column: 17
}end: {...}
- line: 53
- column: 30
}
}callee: MemberExpression {...}
- type: "MemberExpression"
- start: 1153
- end: 1164
loc: {...}
start: {...}
- line: 53
- column: 17
}end: {...}
- line: 53
- column: 28
}
}object: Identifier {...}
- type: "Identifier"
- start: 1153
- end: 1157
loc: {...}
start: {...}
- line: 53
- column: 17
}end: {...}
- line: 53
- column: 21
}
}- name: "Math"
}property: Identifier {...}
- type: "Identifier"
- start: 1158
- end: 1164
loc: {...}
start: {...}
- line: 53
- column: 22
}end: {...}
- line: 53
- column: 28
}
}- name: "random"
}- computed: false
- optional: false
}- arguments: []
- optional: false
}- operator: "*"
right: Identifier {...}
- type: "Identifier"
- start: 1169
- end: 1178
loc: {...}
start: {...}
- line: 53
- column: 33
}end: {...}
- line: 53
- column: 42
}
}- name: "GRID_SIZE"
}
}
]- optional: false
} CallExpression {...}
- type: "CallExpression"
- start: 1187
- end: 1224
loc: {...}
start: {...}
- line: 54
- column: 6
}end: {...}
- line: 54
- column: 43
}
}callee: MemberExpression {...}
- type: "MemberExpression"
- start: 1187
- end: 1197
loc: {...}
start: {...}
- line: 54
- column: 6
}end: {...}
- line: 54
- column: 16
}
}object: Identifier {...}
- type: "Identifier"
- start: 1187
- end: 1191
loc: {...}
start: {...}
- line: 54
- column: 6
}end: {...}
- line: 54
- column: 10
}
}- name: "Math"
}property: Identifier {...}
- type: "Identifier"
- start: 1192
- end: 1197
loc: {...}
start: {...}
- line: 54
- column: 11
}end: {...}
- line: 54
- column: 16
}
}- name: "floor"
}- computed: false
- optional: false
}arguments: [...] (1)
BinaryExpression {...}
- type: "BinaryExpression"
- start: 1198
- end: 1223
loc: {...}
start: {...}
- line: 54
- column: 17
}end: {...}
- line: 54
- column: 42
}
}left: CallExpression {...}
- type: "CallExpression"
- start: 1198
- end: 1211
loc: {...}
start: {...}
- line: 54
- column: 17
}end: {...}
- line: 54
- column: 30
}
}callee: MemberExpression {...}
- type: "MemberExpression"
- start: 1198
- end: 1209
loc: {...}
start: {...}
- line: 54
- column: 17
}end: {...}
- line: 54
- column: 28
}
}object: Identifier {...}
- type: "Identifier"
- start: 1198
- end: 1202
loc: {...}
start: {...}
- line: 54
- column: 17
}end: {...}
- line: 54
- column: 21
}
}- name: "Math"
}property: Identifier {...}
- type: "Identifier"
- start: 1203
- end: 1209
loc: {...}
start: {...}
- line: 54
- column: 22
}end: {...}
- line: 54
- column: 28
}
}- name: "random"
}- computed: false
- optional: false
}- arguments: []
- optional: false
}- operator: "*"
right: Identifier {...}
- type: "Identifier"
- start: 1214
- end: 1223
loc: {...}
start: {...}
- line: 54
- column: 33
}end: {...}
- line: 54
- column: 42
}
}- name: "GRID_SIZE"
}
}
]- optional: false
}
]
}
}
}
]
}test: CallExpression {...}
- type: "CallExpression"
- start: 1243
- end: 1303
loc: {...}
start: {...}
- line: 56
- column: 11
}end: {...}
- line: 56
- column: 71
}
}callee: MemberExpression {...}
- type: "MemberExpression"
- start: 1243
- end: 1253
loc: {...}
start: {...}
- line: 56
- column: 11
}end: {...}
- line: 56
- column: 21
}
}object: Identifier {...}
- type: "Identifier"
- start: 1243
- end: 1248
loc: {...}
start: {...}
- line: 56
- column: 11
}end: {...}
- line: 56
- column: 16
}
}- name: "snake"
}property: Identifier {...}
- type: "Identifier"
- start: 1249
- end: 1253
loc: {...}
start: {...}
- line: 56
- column: 17
}end: {...}
- line: 56
- column: 21
}
}- name: "some"
}- computed: false
- optional: false
}arguments: [...] (1)
ArrowFunctionExpression {...}
- type: "ArrowFunctionExpression"
- start: 1254
- end: 1302
loc: {...}
start: {...}
- line: 56
- column: 22
}end: {...}
- line: 56
- column: 70
}
}- id: null
- expression: true
- generator: false
- async: false
params: [...] (1)
ArrayPattern {...}
- type: "ArrayPattern"
- start: 1255
- end: 1261
loc: {...}
start: {...}
- line: 56
- column: 23
}end: {...}
- line: 56
- column: 29
}
}elements: [...] (2)
Identifier {...}
- type: "Identifier"
- start: 1256
- end: 1257
loc: {...}
start: {...}
- line: 56
- column: 24
}end: {...}
- line: 56
- column: 25
}
}- name: "x"
} Identifier {...}
- type: "Identifier"
- start: 1259
- end: 1260
loc: {...}
start: {...}
- line: 56
- column: 27
}end: {...}
- line: 56
- column: 28
}
}- name: "y"
}
]
}
]body: LogicalExpression {...}
- type: "LogicalExpression"
- start: 1266
- end: 1302
loc: {...}
start: {...}
- line: 56
- column: 34
}end: {...}
- line: 56
- column: 70
}
}left: BinaryExpression {...}
- type: "BinaryExpression"
- start: 1266
- end: 1282
loc: {...}
start: {...}
- line: 56
- column: 34
}end: {...}
- line: 56
- column: 50
}
}left: Identifier {...}
- type: "Identifier"
- start: 1266
- end: 1267
loc: {...}
start: {...}
- line: 56
- column: 34
}end: {...}
- line: 56
- column: 35
}
}- name: "x"
}- operator: "==="
right: MemberExpression {...}
- type: "MemberExpression"
- start: 1272
- end: 1282
loc: {...}
start: {...}
- line: 56
- column: 40
}end: {...}
- line: 56
- column: 50
}
}object: Identifier {...}
- type: "Identifier"
- start: 1272
- end: 1279
loc: {...}
start: {...}
- line: 56
- column: 40
}end: {...}
- line: 56
- column: 47
}
}- name: "newFood"
}property: Literal {...}
- type: "Literal"
- start: 1280
- end: 1281
loc: {...}
start: {...}
- line: 56
- column: 48
}end: {...}
- line: 56
- column: 49
}
}- value: 0
- raw: "0"
}- computed: true
- optional: false
}
}- operator: "&&"
right: BinaryExpression {...}
- type: "BinaryExpression"
- start: 1286
- end: 1302
loc: {...}
start: {...}
- line: 56
- column: 54
}end: {...}
- line: 56
- column: 70
}
}left: Identifier {...}
- type: "Identifier"
- start: 1286
- end: 1287
loc: {...}
start: {...}
- line: 56
- column: 54
}end: {...}
- line: 56
- column: 55
}
}- name: "y"
}- operator: "==="
right: MemberExpression {...}
- type: "MemberExpression"
- start: 1292
- end: 1302
loc: {...}
start: {...}
- line: 56
- column: 60
}end: {...}
- line: 56
- column: 70
}
}object: Identifier {...}
- type: "Identifier"
- start: 1292
- end: 1299
loc: {...}
start: {...}
- line: 56
- column: 60
}end: {...}
- line: 56
- column: 67
}
}- name: "newFood"
}property: Literal {...}
- type: "Literal"
- start: 1300
- end: 1301
loc: {...}
start: {...}
- line: 56
- column: 68
}end: {...}
- line: 56
- column: 69
}
}- value: 1
- raw: "1"
}- computed: true
- optional: false
}
}
}
}
]- optional: false
}
} ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 1311
- end: 1326
loc: {...}
start: {...}
- line: 58
- column: 2
}end: {...}
- line: 58
- column: 17
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 1311
- end: 1325
loc: {...}
start: {...}
- line: 58
- column: 2
}end: {...}
- line: 58
- column: 16
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 1311
- end: 1315
loc: {...}
start: {...}
- line: 58
- column: 2
}end: {...}
- line: 58
- column: 6
}
}- name: "food"
}right: Identifier {...}
- type: "Identifier"
- start: 1318
- end: 1325
loc: {...}
start: {...}
- line: 58
- column: 9
}end: {...}
- line: 58
- column: 16
}
}- name: "newFood"
}
}
}
]
}
} FunctionDeclaration {...}
- type: "FunctionDeclaration"
- start: 1330
- end: 2387
loc: {...}
start: {...}
- line: 61
- column: 0
}end: {...}
- line: 110
- column: 1
}
}id: Identifier {...}
- type: "Identifier"
- start: 1339
- end: 1347
loc: {...}
start: {...}
- line: 61
- column: 9
}end: {...}
- line: 61
- column: 17
}
}- name: "gameLoop"
}- expression: false
- generator: false
- async: false
- params: []
body: BlockStatement {...}
- type: "BlockStatement"
- start: 1350
- end: 2387
loc: {...}
start: {...}
- line: 61
- column: 20
}end: {...}
- line: 110
- column: 1
}
}body: [...] (8)
IfStatement {...}
- type: "IfStatement"
- start: 1354
- end: 1489
loc: {...}
start: {...}
- line: 62
- column: 2
}end: {...}
- line: 68
- column: 3
}
}test: Identifier {...}
- type: "Identifier"
- start: 1358
- end: 1366
loc: {...}
start: {...}
- line: 62
- column: 6
}end: {...}
- line: 62
- column: 14
}
}- name: "gameOver"
}consequent: BlockStatement {...}
- type: "BlockStatement"
- start: 1368
- end: 1489
loc: {...}
start: {...}
- line: 62
- column: 16
}end: {...}
- line: 68
- column: 3
}
}body: [...] (2)
IfStatement {...}
- type: "IfStatement"
- start: 1374
- end: 1473
loc: {...}
start: {...}
- line: 63
- column: 4
}end: {...}
- line: 66
- column: 5
}
}test: Identifier {...}
- type: "Identifier"
- start: 1378
- end: 1394
loc: {...}
start: {...}
- line: 63
- column: 8
}end: {...}
- line: 63
- column: 24
}
}- name: "gameLoopInterval"
}consequent: BlockStatement {...}
- type: "BlockStatement"
- start: 1396
- end: 1473
loc: {...}
start: {...}
- line: 63
- column: 26
}end: {...}
- line: 66
- column: 5
}
}body: [...] (2)
ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 1404
- end: 1436
loc: {...}
start: {...}
- line: 64
- column: 6
}end: {...}
- line: 64
- column: 38
}
}expression: CallExpression {...}
- type: "CallExpression"
- start: 1404
- end: 1435
loc: {...}
start: {...}
- line: 64
- column: 6
}end: {...}
- line: 64
- column: 37
}
}callee: Identifier {...}
- type: "Identifier"
- start: 1404
- end: 1417
loc: {...}
start: {...}
- line: 64
- column: 6
}end: {...}
- line: 64
- column: 19
}
}- name: "clearInterval"
}arguments: [...] (1)
Identifier {...}
- type: "Identifier"
- start: 1418
- end: 1434
loc: {...}
start: {...}
- line: 64
- column: 20
}end: {...}
- line: 64
- column: 36
}
}- name: "gameLoopInterval"
}
]- optional: false
}
} ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 1443
- end: 1467
loc: {...}
start: {...}
- line: 65
- column: 6
}end: {...}
- line: 65
- column: 30
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 1443
- end: 1466
loc: {...}
start: {...}
- line: 65
- column: 6
}end: {...}
- line: 65
- column: 29
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 1443
- end: 1459
loc: {...}
start: {...}
- line: 65
- column: 6
}end: {...}
- line: 65
- column: 22
}
}- name: "gameLoopInterval"
}right: Literal {...}
- type: "Literal"
- start: 1462
- end: 1466
loc: {...}
start: {...}
- line: 65
- column: 25
}end: {...}
- line: 65
- column: 29
}
}- value: null
- raw: "null"
}
}
}
]
}- alternate: null
} ReturnStatement {...}
- type: "ReturnStatement"
- start: 1478
- end: 1485
loc: {...}
start: {...}
- line: 67
- column: 4
}end: {...}
- line: 67
- column: 11
}
}- argument: null
}
]
}- alternate: null
} VariableDeclaration {...}
- type: "VariableDeclaration"
- start: 1493
- end: 1515
loc: {...}
start: {...}
- line: 70
- column: 2
}end: {...}
- line: 70
- column: 24
}
}declarations: [...] (1)
VariableDeclarator {...}
- type: "VariableDeclarator"
- start: 1499
- end: 1514
loc: {...}
start: {...}
- line: 70
- column: 8
}end: {...}
- line: 70
- column: 23
}
}id: Identifier {...}
- type: "Identifier"
- start: 1499
- end: 1503
loc: {...}
start: {...}
- line: 70
- column: 8
}end: {...}
- line: 70
- column: 12
}
}- name: "head"
}init: MemberExpression {...}
- type: "MemberExpression"
- start: 1506
- end: 1514
loc: {...}
start: {...}
- line: 70
- column: 15
}end: {...}
- line: 70
- column: 23
}
}object: Identifier {...}
- type: "Identifier"
- start: 1506
- end: 1511
loc: {...}
start: {...}
- line: 70
- column: 15
}end: {...}
- line: 70
- column: 20
}
}- name: "snake"
}property: Literal {...}
- type: "Literal"
- start: 1512
- end: 1513
loc: {...}
start: {...}
- line: 70
- column: 21
}end: {...}
- line: 70
- column: 22
}
}- value: 0
- raw: "0"
}- computed: true
- optional: false
}
}
]- kind: "const"
} VariableDeclaration {...}
- type: "VariableDeclaration"
- start: 1518
- end: 1548
loc: {...}
start: {...}
- line: 71
- column: 2
}end: {...}
- line: 71
- column: 32
}
}declarations: [...] (1)
VariableDeclarator {...}
- type: "VariableDeclarator"
- start: 1522
- end: 1547
loc: {...}
start: {...}
- line: 71
- column: 6
}end: {...}
- line: 71
- column: 31
}
}id: Identifier {...}
- type: "Identifier"
- start: 1522
- end: 1529
loc: {...}
start: {...}
- line: 71
- column: 6
}end: {...}
- line: 71
- column: 31
}
}- name: "newHead"
}- init: null
}
]- kind: "let"
} SwitchStatement {...}
- type: "SwitchStatement"
- start: 1585
- end: 1888
loc: {...}
start: {...}
- line: 74
- column: 2
}end: {...}
- line: 87
- column: 3
}
}discriminant: Identifier {...}
- type: "Identifier"
- start: 1593
- end: 1602
loc: {...}
start: {...}
- line: 74
- column: 10
}end: {...}
- line: 74
- column: 19
}
}- name: "direction"
}cases: [...] (4)
SwitchCase {...}
- type: "SwitchCase"
- start: 1610
- end: 1673
loc: {...}
start: {...}
- line: 75
- column: 4
}end: {...}
- line: 77
- column: 12
}
}consequent: [...] (2)
ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 1627
- end: 1660
loc: {...}
start: {...}
- line: 76
- column: 6
}end: {...}
- line: 76
- column: 39
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 1627
- end: 1659
loc: {...}
start: {...}
- line: 76
- column: 6
}end: {...}
- line: 76
- column: 38
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 1627
- end: 1634
loc: {...}
start: {...}
- line: 76
- column: 6
}end: {...}
- line: 76
- column: 13
}
}- name: "newHead"
}right: ArrayExpression {...}
- type: "ArrayExpression"
- start: 1637
- end: 1659
loc: {...}
start: {...}
- line: 76
- column: 16
}end: {...}
- line: 76
- column: 38
}
}elements: [...] (2)
MemberExpression {...}
- type: "MemberExpression"
- start: 1638
- end: 1645
loc: {...}
start: {...}
- line: 76
- column: 17
}end: {...}
- line: 76
- column: 24
}
}object: Identifier {...}
- type: "Identifier"
- start: 1638
- end: 1642
loc: {...}
start: {...}
- line: 76
- column: 17
}end: {...}
- line: 76
- column: 21
}
}- name: "head"
}property: Literal {...}
- type: "Literal"
- start: 1643
- end: 1644
loc: {...}
start: {...}
- line: 76
- column: 22
}end: {...}
- line: 76
- column: 23
}
}- value: 0
- raw: "0"
}- computed: true
- optional: false
} BinaryExpression {...}
- type: "BinaryExpression"
- start: 1647
- end: 1658
loc: {...}
start: {...}
- line: 76
- column: 26
}end: {...}
- line: 76
- column: 37
}
}left: MemberExpression {...}
- type: "MemberExpression"
- start: 1647
- end: 1654
loc: {...}
start: {...}
- line: 76
- column: 26
}end: {...}
- line: 76
- column: 33
}
}object: Identifier {...}
- type: "Identifier"
- start: 1647
- end: 1651
loc: {...}
start: {...}
- line: 76
- column: 26
}end: {...}
- line: 76
- column: 30
}
}- name: "head"
}property: Literal {...}
- type: "Literal"
- start: 1652
- end: 1653
loc: {...}
start: {...}
- line: 76
- column: 31
}end: {...}
- line: 76
- column: 32
}
}- value: 1
- raw: "1"
}- computed: true
- optional: false
}- operator: "-"
right: Literal {...}
- type: "Literal"
- start: 1657
- end: 1658
loc: {...}
start: {...}
- line: 76
- column: 36
}end: {...}
- line: 76
- column: 37
}
}- value: 1
- raw: "1"
}
}
]
}
}
} BreakStatement {...}
- type: "BreakStatement"
- start: 1667
- end: 1673
loc: {...}
start: {...}
- line: 77
- column: 6
}end: {...}
- line: 77
- column: 12
}
}- label: null
}
]test: Literal {...}
- type: "Literal"
- start: 1615
- end: 1619
loc: {...}
start: {...}
- line: 75
- column: 9
}end: {...}
- line: 75
- column: 13
}
}- value: "up"
- raw: "'up'"
}
} SwitchCase {...}
- type: "SwitchCase"
- start: 1678
- end: 1743
loc: {...}
start: {...}
- line: 78
- column: 4
}end: {...}
- line: 80
- column: 12
}
}consequent: [...] (2)
ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 1697
- end: 1730
loc: {...}
start: {...}
- line: 79
- column: 6
}end: {...}
- line: 79
- column: 39
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 1697
- end: 1729
loc: {...}
start: {...}
- line: 79
- column: 6
}end: {...}
- line: 79
- column: 38
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 1697
- end: 1704
loc: {...}
start: {...}
- line: 79
- column: 6
}end: {...}
- line: 79
- column: 13
}
}- name: "newHead"
}right: ArrayExpression {...}
- type: "ArrayExpression"
- start: 1707
- end: 1729
loc: {...}
start: {...}
- line: 79
- column: 16
}end: {...}
- line: 79
- column: 38
}
}elements: [...] (2)
MemberExpression {...}
- type: "MemberExpression"
- start: 1708
- end: 1715
loc: {...}
start: {...}
- line: 79
- column: 17
}end: {...}
- line: 79
- column: 24
}
}object: Identifier {...}
- type: "Identifier"
- start: 1708
- end: 1712
loc: {...}
start: {...}
- line: 79
- column: 17
}end: {...}
- line: 79
- column: 21
}
}- name: "head"
}property: Literal {...}
- type: "Literal"
- start: 1713
- end: 1714
loc: {...}
start: {...}
- line: 79
- column: 22
}end: {...}
- line: 79
- column: 23
}
}- value: 0
- raw: "0"
}- computed: true
- optional: false
} BinaryExpression {...}
- type: "BinaryExpression"
- start: 1717
- end: 1728
loc: {...}
start: {...}
- line: 79
- column: 26
}end: {...}
- line: 79
- column: 37
}
}left: MemberExpression {...}
- type: "MemberExpression"
- start: 1717
- end: 1724
loc: {...}
start: {...}
- line: 79
- column: 26
}end: {...}
- line: 79
- column: 33
}
}object: Identifier {...}
- type: "Identifier"
- start: 1717
- end: 1721
loc: {...}
start: {...}
- line: 79
- column: 26
}end: {...}
- line: 79
- column: 30
}
}- name: "head"
}property: Literal {...}
- type: "Literal"
- start: 1722
- end: 1723
loc: {...}
start: {...}
- line: 79
- column: 31
}end: {...}
- line: 79
- column: 32
}
}- value: 1
- raw: "1"
}- computed: true
- optional: false
}- operator: "+"
right: Literal {...}
- type: "Literal"
- start: 1727
- end: 1728
loc: {...}
start: {...}
- line: 79
- column: 36
}end: {...}
- line: 79
- column: 37
}
}- value: 1
- raw: "1"
}
}
]
}
}
} BreakStatement {...}
- type: "BreakStatement"
- start: 1737
- end: 1743
loc: {...}
start: {...}
- line: 80
- column: 6
}end: {...}
- line: 80
- column: 12
}
}- label: null
}
]test: Literal {...}
- type: "Literal"
- start: 1683
- end: 1689
loc: {...}
start: {...}
- line: 78
- column: 9
}end: {...}
- line: 78
- column: 15
}
}- value: "down"
- raw: "'down'"
}
} SwitchCase {...}
- type: "SwitchCase"
- start: 1748
- end: 1813
loc: {...}
start: {...}
- line: 81
- column: 4
}end: {...}
- line: 83
- column: 12
}
}consequent: [...] (2)
ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 1767
- end: 1800
loc: {...}
start: {...}
- line: 82
- column: 6
}end: {...}
- line: 82
- column: 39
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 1767
- end: 1799
loc: {...}
start: {...}
- line: 82
- column: 6
}end: {...}
- line: 82
- column: 38
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 1767
- end: 1774
loc: {...}
start: {...}
- line: 82
- column: 6
}end: {...}
- line: 82
- column: 13
}
}- name: "newHead"
}right: ArrayExpression {...}
- type: "ArrayExpression"
- start: 1777
- end: 1799
loc: {...}
start: {...}
- line: 82
- column: 16
}end: {...}
- line: 82
- column: 38
}
}elements: [...] (2)
BinaryExpression {...}
- type: "BinaryExpression"
- start: 1778
- end: 1789
loc: {...}
start: {...}
- line: 82
- column: 17
}end: {...}
- line: 82
- column: 28
}
}left: MemberExpression {...}
- type: "MemberExpression"
- start: 1778
- end: 1785
loc: {...}
start: {...}
- line: 82
- column: 17
}end: {...}
- line: 82
- column: 24
}
}object: Identifier {...}
- type: "Identifier"
- start: 1778
- end: 1782
loc: {...}
start: {...}
- line: 82
- column: 17
}end: {...}
- line: 82
- column: 21
}
}- name: "head"
}property: Literal {...}
- type: "Literal"
- start: 1783
- end: 1784
loc: {...}
start: {...}
- line: 82
- column: 22
}end: {...}
- line: 82
- column: 23
}
}- value: 0
- raw: "0"
}- computed: true
- optional: false
}- operator: "-"
right: Literal {...}
- type: "Literal"
- start: 1788
- end: 1789
loc: {...}
start: {...}
- line: 82
- column: 27
}end: {...}
- line: 82
- column: 28
}
}- value: 1
- raw: "1"
}
} MemberExpression {...}
- type: "MemberExpression"
- start: 1791
- end: 1798
loc: {...}
start: {...}
- line: 82
- column: 30
}end: {...}
- line: 82
- column: 37
}
}object: Identifier {...}
- type: "Identifier"
- start: 1791
- end: 1795
loc: {...}
start: {...}
- line: 82
- column: 30
}end: {...}
- line: 82
- column: 34
}
}- name: "head"
}property: Literal {...}
- type: "Literal"
- start: 1796
- end: 1797
loc: {...}
start: {...}
- line: 82
- column: 35
}end: {...}
- line: 82
- column: 36
}
}- value: 1
- raw: "1"
}- computed: true
- optional: false
}
]
}
}
} BreakStatement {...}
- type: "BreakStatement"
- start: 1807
- end: 1813
loc: {...}
start: {...}
- line: 83
- column: 6
}end: {...}
- line: 83
- column: 12
}
}- label: null
}
]test: Literal {...}
- type: "Literal"
- start: 1753
- end: 1759
loc: {...}
start: {...}
- line: 81
- column: 9
}end: {...}
- line: 81
- column: 15
}
}- value: "left"
- raw: "'left'"
}
} SwitchCase {...}
- type: "SwitchCase"
- start: 1818
- end: 1884
loc: {...}
start: {...}
- line: 84
- column: 4
}end: {...}
- line: 86
- column: 12
}
}consequent: [...] (2)
ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 1838
- end: 1871
loc: {...}
start: {...}
- line: 85
- column: 6
}end: {...}
- line: 85
- column: 39
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 1838
- end: 1870
loc: {...}
start: {...}
- line: 85
- column: 6
}end: {...}
- line: 85
- column: 38
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 1838
- end: 1845
loc: {...}
start: {...}
- line: 85
- column: 6
}end: {...}
- line: 85
- column: 13
}
}- name: "newHead"
}right: ArrayExpression {...}
- type: "ArrayExpression"
- start: 1848
- end: 1870
loc: {...}
start: {...}
- line: 85
- column: 16
}end: {...}
- line: 85
- column: 38
}
}elements: [...] (2)
BinaryExpression {...}
- type: "BinaryExpression"
- start: 1849
- end: 1860
loc: {...}
start: {...}
- line: 85
- column: 17
}end: {...}
- line: 85
- column: 28
}
}left: MemberExpression {...}
- type: "MemberExpression"
- start: 1849
- end: 1856
loc: {...}
start: {...}
- line: 85
- column: 17
}end: {...}
- line: 85
- column: 24
}
}object: Identifier {...}
- type: "Identifier"
- start: 1849
- end: 1853
loc: {...}
start: {...}
- line: 85
- column: 17
}end: {...}
- line: 85
- column: 21
}
}- name: "head"
}property: Literal {...}
- type: "Literal"
- start: 1854
- end: 1855
loc: {...}
start: {...}
- line: 85
- column: 22
}end: {...}
- line: 85
- column: 23
}
}- value: 0
- raw: "0"
}- computed: true
- optional: false
}- operator: "+"
right: Literal {...}
- type: "Literal"
- start: 1859
- end: 1860
loc: {...}
start: {...}
- line: 85
- column: 27
}end: {...}
- line: 85
- column: 28
}
}- value: 1
- raw: "1"
}
} MemberExpression {...}
- type: "MemberExpression"
- start: 1862
- end: 1869
loc: {...}
start: {...}
- line: 85
- column: 30
}end: {...}
- line: 85
- column: 37
}
}object: Identifier {...}
- type: "Identifier"
- start: 1862
- end: 1866
loc: {...}
start: {...}
- line: 85
- column: 30
}end: {...}
- line: 85
- column: 34
}
}- name: "head"
}property: Literal {...}
- type: "Literal"
- start: 1867
- end: 1868
loc: {...}
start: {...}
- line: 85
- column: 35
}end: {...}
- line: 85
- column: 36
}
}- value: 1
- raw: "1"
}- computed: true
- optional: false
}
]
}
}
} BreakStatement {...}
- type: "BreakStatement"
- start: 1878
- end: 1884
loc: {...}
start: {...}
- line: 86
- column: 6
}end: {...}
- line: 86
- column: 12
}
}- label: null
}
]test: Literal {...}
- type: "Literal"
- start: 1823
- end: 1830
loc: {...}
start: {...}
- line: 84
- column: 9
}end: {...}
- line: 84
- column: 16
}
}- value: "right"
- raw: "'right'"
}
}
]leadingComments: [...] (1)
Line {...}
- type: "Line"
- value: " Calculate new head position"
- start: 1552
- end: 1582
}
]
} IfStatement {...}
- type: "IfStatement"
- start: 1918
- end: 2136
loc: {...}
start: {...}
- line: 90
- column: 2
}end: {...}
- line: 99
- column: 3
}
}test: LogicalExpression {...}
- type: "LogicalExpression"
- start: 1927
- end: 2093
loc: {...}
start: {...}
- line: 91
- column: 4
}end: {...}
- line: 95
- column: 64
}
}left: LogicalExpression {...}
- type: "LogicalExpression"
- start: 1927
- end: 2025
loc: {...}
start: {...}
- line: 91
- column: 4
}end: {...}
- line: 94
- column: 27
}
}left: LogicalExpression {...}
- type: "LogicalExpression"
- start: 1927
- end: 1994
loc: {...}
start: {...}
- line: 91
- column: 4
}end: {...}
- line: 93
- column: 18
}
}left: LogicalExpression {...}
- type: "LogicalExpression"
- start: 1927
- end: 1972
loc: {...}
start: {...}
- line: 91
- column: 4
}end: {...}
- line: 92
- column: 27
}
}left: BinaryExpression {...}
- type: "BinaryExpression"
- start: 1927
- end: 1941
loc: {...}
start: {...}
- line: 91
- column: 4
}end: {...}
- line: 91
- column: 18
}
}left: MemberExpression {...}
- type: "MemberExpression"
- start: 1927
- end: 1937
loc: {...}
start: {...}
- line: 91
- column: 4
}end: {...}
- line: 91
- column: 14
}
}object: Identifier {...}
- type: "Identifier"
- start: 1927
- end: 1934
loc: {...}
start: {...}
- line: 91
- column: 4
}end: {...}
- line: 91
- column: 11
}
}- name: "newHead"
}property: Literal {...}
- type: "Literal"
- start: 1935
- end: 1936
loc: {...}
start: {...}
- line: 91
- column: 12
}end: {...}
- line: 91
- column: 13
}
}- value: 0
- raw: "0"
}- computed: true
- optional: false
}- operator: "<"
right: Literal {...}
- type: "Literal"
- start: 1940
- end: 1941
loc: {...}
start: {...}
- line: 91
- column: 17
}end: {...}
- line: 91
- column: 18
}
}- value: 0
- raw: "0"
}
}- operator: "||"
right: BinaryExpression {...}
- type: "BinaryExpression"
- start: 1949
- end: 1972
loc: {...}
start: {...}
- line: 92
- column: 4
}end: {...}
- line: 92
- column: 27
}
}left: MemberExpression {...}
- type: "MemberExpression"
- start: 1949
- end: 1959
loc: {...}
start: {...}
- line: 92
- column: 4
}end: {...}
- line: 92
- column: 14
}
}object: Identifier {...}
- type: "Identifier"
- start: 1949
- end: 1956
loc: {...}
start: {...}
- line: 92
- column: 4
}end: {...}
- line: 92
- column: 11
}
}- name: "newHead"
}property: Literal {...}
- type: "Literal"
- start: 1957
- end: 1958
loc: {...}
start: {...}
- line: 92
- column: 12
}end: {...}
- line: 92
- column: 13
}
}- value: 0
- raw: "0"
}- computed: true
- optional: false
}- operator: ">="
right: Identifier {...}
- type: "Identifier"
- start: 1963
- end: 1972
loc: {...}
start: {...}
- line: 92
- column: 18
}end: {...}
- line: 92
- column: 27
}
}- name: "GRID_SIZE"
}
}
}- operator: "||"
right: BinaryExpression {...}
- type: "BinaryExpression"
- start: 1980
- end: 1994
loc: {...}
start: {...}
- line: 93
- column: 4
}end: {...}
- line: 93
- column: 18
}
}left: MemberExpression {...}
- type: "MemberExpression"
- start: 1980
- end: 1990
loc: {...}
start: {...}
- line: 93
- column: 4
}end: {...}
- line: 93
- column: 14
}
}object: Identifier {...}
- type: "Identifier"
- start: 1980
- end: 1987
loc: {...}
start: {...}
- line: 93
- column: 4
}end: {...}
- line: 93
- column: 11
}
}- name: "newHead"
}property: Literal {...}
- type: "Literal"
- start: 1988
- end: 1989
loc: {...}
start: {...}
- line: 93
- column: 12
}end: {...}
- line: 93
- column: 13
}
}- value: 1
- raw: "1"
}- computed: true
- optional: false
}- operator: "<"
right: Literal {...}
- type: "Literal"
- start: 1993
- end: 1994
loc: {...}
start: {...}
- line: 93
- column: 17
}end: {...}
- line: 93
- column: 18
}
}- value: 0
- raw: "0"
}
}
}- operator: "||"
right: BinaryExpression {...}
- type: "BinaryExpression"
- start: 2002
- end: 2025
loc: {...}
start: {...}
- line: 94
- column: 4
}end: {...}
- line: 94
- column: 27
}
}left: MemberExpression {...}
- type: "MemberExpression"
- start: 2002
- end: 2012
loc: {...}
start: {...}
- line: 94
- column: 4
}end: {...}
- line: 94
- column: 14
}
}object: Identifier {...}
- type: "Identifier"
- start: 2002
- end: 2009
loc: {...}
start: {...}
- line: 94
- column: 4
}end: {...}
- line: 94
- column: 11
}
}- name: "newHead"
}property: Literal {...}
- type: "Literal"
- start: 2010
- end: 2011
loc: {...}
start: {...}
- line: 94
- column: 12
}end: {...}
- line: 94
- column: 13
}
}- value: 1
- raw: "1"
}- computed: true
- optional: false
}- operator: ">="
right: Identifier {...}
- type: "Identifier"
- start: 2016
- end: 2025
loc: {...}
start: {...}
- line: 94
- column: 18
}end: {...}
- line: 94
- column: 27
}
}- name: "GRID_SIZE"
}
}
}- operator: "||"
right: CallExpression {...}
- type: "CallExpression"
- start: 2033
- end: 2093
loc: {...}
start: {...}
- line: 95
- column: 4
}end: {...}
- line: 95
- column: 64
}
}callee: MemberExpression {...}
- type: "MemberExpression"
- start: 2033
- end: 2043
loc: {...}
start: {...}
- line: 95
- column: 4
}end: {...}
- line: 95
- column: 14
}
}object: Identifier {...}
- type: "Identifier"
- start: 2033
- end: 2038
loc: {...}
start: {...}
- line: 95
- column: 4
}end: {...}
- line: 95
- column: 9
}
}- name: "snake"
}property: Identifier {...}
- type: "Identifier"
- start: 2039
- end: 2043
loc: {...}
start: {...}
- line: 95
- column: 10
}end: {...}
- line: 95
- column: 14
}
}- name: "some"
}- computed: false
- optional: false
}arguments: [...] (1)
ArrowFunctionExpression {...}
- type: "ArrowFunctionExpression"
- start: 2044
- end: 2092
loc: {...}
start: {...}
- line: 95
- column: 15
}end: {...}
- line: 95
- column: 63
}
}- id: null
- expression: true
- generator: false
- async: false
params: [...] (1)
ArrayPattern {...}
- type: "ArrayPattern"
- start: 2045
- end: 2051
loc: {...}
start: {...}
- line: 95
- column: 16
}end: {...}
- line: 95
- column: 22
}
}elements: [...] (2)
Identifier {...}
- type: "Identifier"
- start: 2046
- end: 2047
loc: {...}
start: {...}
- line: 95
- column: 17
}end: {...}
- line: 95
- column: 18
}
}- name: "x"
} Identifier {...}
- type: "Identifier"
- start: 2049
- end: 2050
loc: {...}
start: {...}
- line: 95
- column: 20
}end: {...}
- line: 95
- column: 21
}
}- name: "y"
}
]
}
]body: LogicalExpression {...}
- type: "LogicalExpression"
- start: 2056
- end: 2092
loc: {...}
start: {...}
- line: 95
- column: 27
}end: {...}
- line: 95
- column: 63
}
}left: BinaryExpression {...}
- type: "BinaryExpression"
- start: 2056
- end: 2072
loc: {...}
start: {...}
- line: 95
- column: 27
}end: {...}
- line: 95
- column: 43
}
}left: Identifier {...}
- type: "Identifier"
- start: 2056
- end: 2057
loc: {...}
start: {...}
- line: 95
- column: 27
}end: {...}
- line: 95
- column: 28
}
}- name: "x"
}- operator: "==="
right: MemberExpression {...}
- type: "MemberExpression"
- start: 2062
- end: 2072
loc: {...}
start: {...}
- line: 95
- column: 33
}end: {...}
- line: 95
- column: 43
}
}object: Identifier {...}
- type: "Identifier"
- start: 2062
- end: 2069
loc: {...}
start: {...}
- line: 95
- column: 33
}end: {...}
- line: 95
- column: 40
}
}- name: "newHead"
}property: Literal {...}
- type: "Literal"
- start: 2070
- end: 2071
loc: {...}
start: {...}
- line: 95
- column: 41
}end: {...}
- line: 95
- column: 42
}
}- value: 0
- raw: "0"
}- computed: true
- optional: false
}
}- operator: "&&"
right: BinaryExpression {...}
- type: "BinaryExpression"
- start: 2076
- end: 2092
loc: {...}
start: {...}
- line: 95
- column: 47
}end: {...}
- line: 95
- column: 63
}
}left: Identifier {...}
- type: "Identifier"
- start: 2076
- end: 2077
loc: {...}
start: {...}
- line: 95
- column: 47
}end: {...}
- line: 95
- column: 48
}
}- name: "y"
}- operator: "==="
right: MemberExpression {...}
- type: "MemberExpression"
- start: 2082
- end: 2092
loc: {...}
start: {...}
- line: 95
- column: 53
}end: {...}
- line: 95
- column: 63
}
}object: Identifier {...}
- type: "Identifier"
- start: 2082
- end: 2089
loc: {...}
start: {...}
- line: 95
- column: 53
}end: {...}
- line: 95
- column: 60
}
}- name: "newHead"
}property: Literal {...}
- type: "Literal"
- start: 2090
- end: 2091
loc: {...}
start: {...}
- line: 95
- column: 61
}end: {...}
- line: 95
- column: 62
}
}- value: 1
- raw: "1"
}- computed: true
- optional: false
}
}
}
}
]- optional: false
}
}consequent: BlockStatement {...}
- type: "BlockStatement"
- start: 2098
- end: 2136
loc: {...}
start: {...}
- line: 96
- column: 4
}end: {...}
- line: 99
- column: 3
}
}body: [...] (2)
ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 2104
- end: 2120
loc: {...}
start: {...}
- line: 97
- column: 4
}end: {...}
- line: 97
- column: 20
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 2104
- end: 2119
loc: {...}
start: {...}
- line: 97
- column: 4
}end: {...}
- line: 97
- column: 19
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 2104
- end: 2112
loc: {...}
start: {...}
- line: 97
- column: 4
}end: {...}
- line: 97
- column: 12
}
}- name: "gameOver"
}right: Literal {...}
- type: "Literal"
- start: 2115
- end: 2119
loc: {...}
start: {...}
- line: 97
- column: 15
}end: {...}
- line: 97
- column: 19
}
}- value: true
- raw: "true"
}
}
} ReturnStatement {...}
- type: "ReturnStatement"
- start: 2125
- end: 2132
loc: {...}
start: {...}
- line: 98
- column: 4
}end: {...}
- line: 98
- column: 11
}
}- argument: null
}
]
}- alternate: null
leadingComments: [...] (1)
Line {...}
- type: "Line"
- value: " Check for collisions"
- start: 1892
- end: 1915
}
]
} VariableDeclaration {...}
- type: "VariableDeclaration"
- start: 2168
- end: 2233
loc: {...}
start: {...}
- line: 102
- column: 2
}end: {...}
- line: 102
- column: 67
}
}declarations: [...] (1)
VariableDeclarator {...}
- type: "VariableDeclarator"
- start: 2174
- end: 2232
loc: {...}
start: {...}
- line: 102
- column: 8
}end: {...}
- line: 102
- column: 66
}
}id: Identifier {...}
- type: "Identifier"
- start: 2174
- end: 2181
loc: {...}
start: {...}
- line: 102
- column: 8
}end: {...}
- line: 102
- column: 15
}
}- name: "ateFood"
}init: LogicalExpression {...}
- type: "LogicalExpression"
- start: 2184
- end: 2232
loc: {...}
start: {...}
- line: 102
- column: 18
}end: {...}
- line: 102
- column: 66
}
}left: BinaryExpression {...}
- type: "BinaryExpression"
- start: 2184
- end: 2206
loc: {...}
start: {...}
- line: 102
- column: 18
}end: {...}
- line: 102
- column: 40
}
}left: MemberExpression {...}
- type: "MemberExpression"
- start: 2184
- end: 2194
loc: {...}
start: {...}
- line: 102
- column: 18
}end: {...}
- line: 102
- column: 28
}
}object: Identifier {...}
- type: "Identifier"
- start: 2184
- end: 2191
loc: {...}
start: {...}
- line: 102
- column: 18
}end: {...}
- line: 102
- column: 25
}
}- name: "newHead"
}property: Literal {...}
- type: "Literal"
- start: 2192
- end: 2193
loc: {...}
start: {...}
- line: 102
- column: 26
}end: {...}
- line: 102
- column: 27
}
}- value: 0
- raw: "0"
}- computed: true
- optional: false
}- operator: "==="
right: MemberExpression {...}
- type: "MemberExpression"
- start: 2199
- end: 2206
loc: {...}
start: {...}
- line: 102
- column: 33
}end: {...}
- line: 102
- column: 40
}
}object: Identifier {...}
- type: "Identifier"
- start: 2199
- end: 2203
loc: {...}
start: {...}
- line: 102
- column: 33
}end: {...}
- line: 102
- column: 37
}
}- name: "food"
}property: Literal {...}
- type: "Literal"
- start: 2204
- end: 2205
loc: {...}
start: {...}
- line: 102
- column: 38
}end: {...}
- line: 102
- column: 39
}
}- value: 0
- raw: "0"
}- computed: true
- optional: false
}
}- operator: "&&"
right: BinaryExpression {...}
- type: "BinaryExpression"
- start: 2210
- end: 2232
loc: {...}
start: {...}
- line: 102
- column: 44
}end: {...}
- line: 102
- column: 66
}
}left: MemberExpression {...}
- type: "MemberExpression"
- start: 2210
- end: 2220
loc: {...}
start: {...}
- line: 102
- column: 44
}end: {...}
- line: 102
- column: 54
}
}object: Identifier {...}
- type: "Identifier"
- start: 2210
- end: 2217
loc: {...}
start: {...}
- line: 102
- column: 44
}end: {...}
- line: 102
- column: 51
}
}- name: "newHead"
}property: Literal {...}
- type: "Literal"
- start: 2218
- end: 2219
loc: {...}
start: {...}
- line: 102
- column: 52
}end: {...}
- line: 102
- column: 53
}
}- value: 1
- raw: "1"
}- computed: true
- optional: false
}- operator: "==="
right: MemberExpression {...}
- type: "MemberExpression"
- start: 2225
- end: 2232
loc: {...}
start: {...}
- line: 102
- column: 59
}end: {...}
- line: 102
- column: 66
}
}object: Identifier {...}
- type: "Identifier"
- start: 2225
- end: 2229
loc: {...}
start: {...}
- line: 102
- column: 59
}end: {...}
- line: 102
- column: 63
}
}- name: "food"
}property: Literal {...}
- type: "Literal"
- start: 2230
- end: 2231
loc: {...}
start: {...}
- line: 102
- column: 64
}end: {...}
- line: 102
- column: 65
}
}- value: 1
- raw: "1"
}- computed: true
- optional: false
}
}
}
}
]- kind: "const"
leadingComments: [...] (1)
Line {...}
- type: "Line"
- value: " Check if food is eaten"
- start: 2140
- end: 2165
}
]
} IfStatement {...}
- type: "IfStatement"
- start: 2236
- end: 2288
loc: {...}
start: {...}
- line: 103
- column: 2
}end: {...}
- line: 106
- column: 3
}
}test: Identifier {...}
- type: "Identifier"
- start: 2240
- end: 2247
loc: {...}
start: {...}
- line: 103
- column: 6
}end: {...}
- line: 103
- column: 13
}
}- name: "ateFood"
}consequent: BlockStatement {...}
- type: "BlockStatement"
- start: 2249
- end: 2288
loc: {...}
start: {...}
- line: 103
- column: 15
}end: {...}
- line: 106
- column: 3
}
}body: [...] (2)
ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 2255
- end: 2267
loc: {...}
start: {...}
- line: 104
- column: 4
}end: {...}
- line: 104
- column: 16
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 2255
- end: 2266
loc: {...}
start: {...}
- line: 104
- column: 4
}end: {...}
- line: 104
- column: 15
}
}- operator: "+="
left: Identifier {...}
- type: "Identifier"
- start: 2255
- end: 2260
loc: {...}
start: {...}
- line: 104
- column: 4
}end: {...}
- line: 104
- column: 9
}
}- name: "score"
}right: Literal {...}
- type: "Literal"
- start: 2264
- end: 2266
loc: {...}
start: {...}
- line: 104
- column: 13
}end: {...}
- line: 104
- column: 15
}
}- value: 10
- raw: "10"
}
}
} ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 2272
- end: 2284
loc: {...}
start: {...}
- line: 105
- column: 4
}end: {...}
- line: 105
- column: 16
}
}expression: CallExpression {...}
- type: "CallExpression"
- start: 2272
- end: 2283
loc: {...}
start: {...}
- line: 105
- column: 4
}end: {...}
- line: 105
- column: 15
}
}callee: Identifier {...}
- type: "Identifier"
- start: 2272
- end: 2281
loc: {...}
start: {...}
- line: 105
- column: 4
}end: {...}
- line: 105
- column: 13
}
}- name: "placeFood"
}- arguments: []
- optional: false
}
}
]
}- alternate: null
} ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 2319
- end: 2385
loc: {...}
start: {...}
- line: 109
- column: 2
}end: {...}
- line: 109
- column: 68
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 2319
- end: 2384
loc: {...}
start: {...}
- line: 109
- column: 2
}end: {...}
- line: 109
- column: 67
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 2319
- end: 2324
loc: {...}
start: {...}
- line: 109
- column: 2
}end: {...}
- line: 109
- column: 7
}
}- name: "snake"
}right: ArrayExpression {...}
- type: "ArrayExpression"
- start: 2327
- end: 2384
loc: {...}
start: {...}
- line: 109
- column: 10
}end: {...}
- line: 109
- column: 67
}
}elements: [...] (2)
Identifier {...}
- type: "Identifier"
- start: 2328
- end: 2335
loc: {...}
start: {...}
- line: 109
- column: 11
}end: {...}
- line: 109
- column: 18
}
}- name: "newHead"
} SpreadElement {...}
- type: "SpreadElement"
- start: 2337
- end: 2383
loc: {...}
start: {...}
- line: 109
- column: 20
}end: {...}
- line: 109
- column: 66
}
}argument: CallExpression {...}
- type: "CallExpression"
- start: 2340
- end: 2383
loc: {...}
start: {...}
- line: 109
- column: 23
}end: {...}
- line: 109
- column: 66
}
}callee: MemberExpression {...}
- type: "MemberExpression"
- start: 2340
- end: 2351
loc: {...}
start: {...}
- line: 109
- column: 23
}end: {...}
- line: 109
- column: 34
}
}object: Identifier {...}
- type: "Identifier"
- start: 2340
- end: 2345
loc: {...}
start: {...}
- line: 109
- column: 23
}end: {...}
- line: 109
- column: 28
}
}- name: "snake"
}property: Identifier {...}
- type: "Identifier"
- start: 2346
- end: 2351
loc: {...}
start: {...}
- line: 109
- column: 29
}end: {...}
- line: 109
- column: 34
}
}- name: "slice"
}- computed: false
- optional: false
}arguments: [...] (2)
Literal {...}
- type: "Literal"
- start: 2352
- end: 2353
loc: {...}
start: {...}
- line: 109
- column: 35
}end: {...}
- line: 109
- column: 36
}
}- value: 0
- raw: "0"
} ConditionalExpression {...}
- type: "ConditionalExpression"
- start: 2355
- end: 2382
loc: {...}
start: {...}
- line: 109
- column: 38
}end: {...}
- line: 109
- column: 65
}
}test: Identifier {...}
- type: "Identifier"
- start: 2355
- end: 2362
loc: {...}
start: {...}
- line: 109
- column: 38
}end: {...}
- line: 109
- column: 45
}
}- name: "ateFood"
}consequent: MemberExpression {...}
- type: "MemberExpression"
- start: 2365
- end: 2377
loc: {...}
start: {...}
- line: 109
- column: 48
}end: {...}
- line: 109
- column: 60
}
}object: Identifier {...}
- type: "Identifier"
- start: 2365
- end: 2370
loc: {...}
start: {...}
- line: 109
- column: 48
}end: {...}
- line: 109
- column: 53
}
}- name: "snake"
}property: Identifier {...}
- type: "Identifier"
- start: 2371
- end: 2377
loc: {...}
start: {...}
- line: 109
- column: 54
}end: {...}
- line: 109
- column: 60
}
}- name: "length"
}- computed: false
- optional: false
}alternate: UnaryExpression {...}
- type: "UnaryExpression"
- start: 2380
- end: 2382
loc: {...}
start: {...}
- line: 109
- column: 63
}end: {...}
- line: 109
- column: 65
}
}- operator: "-"
- prefix: true
argument: Literal {...}
- type: "Literal"
- start: 2381
- end: 2382
loc: {...}
start: {...}
- line: 109
- column: 64
}end: {...}
- line: 109
- column: 65
}
}- value: 1
- raw: "1"
}
}
}
]- optional: false
}
}
]
}
}leadingComments: [...] (1)
Line {...}
- type: "Line"
- value: " Update snake position"
- start: 2292
- end: 2316
}
]
}
]
}
} FunctionDeclaration {...}
- type: "FunctionDeclaration"
- start: 2389
- end: 2809
loc: {...}
start: {...}
- line: 112
- column: 0
}end: {...}
- line: 127
- column: 1
}
}id: Identifier {...}
- type: "Identifier"
- start: 2398
- end: 2411
loc: {...}
start: {...}
- line: 112
- column: 9
}end: {...}
- line: 112
- column: 22
}
}- name: "handleKeydown"
}- expression: false
- generator: false
- async: false
params: [...] (1)
Identifier {...}
- type: "Identifier"
- start: 2412
- end: 2417
loc: {...}
start: {...}
- line: 112
- column: 23
}end: {...}
- line: 112
- column: 43
}
}- name: "event"
}
]body: BlockStatement {...}
- type: "BlockStatement"
- start: 2434
- end: 2809
loc: {...}
start: {...}
- line: 112
- column: 45
}end: {...}
- line: 127
- column: 1
}
}body: [...] (1)
SwitchStatement {...}
- type: "SwitchStatement"
- start: 2438
- end: 2807
loc: {...}
start: {...}
- line: 113
- column: 2
}end: {...}
- line: 126
- column: 3
}
}discriminant: MemberExpression {...}
- type: "MemberExpression"
- start: 2446
- end: 2455
loc: {...}
start: {...}
- line: 113
- column: 10
}end: {...}
- line: 113
- column: 19
}
}object: Identifier {...}
- type: "Identifier"
- start: 2446
- end: 2451
loc: {...}
start: {...}
- line: 113
- column: 10
}end: {...}
- line: 113
- column: 15
}
}- name: "event"
}property: Identifier {...}
- type: "Identifier"
- start: 2452
- end: 2455
loc: {...}
start: {...}
- line: 113
- column: 16
}end: {...}
- line: 113
- column: 19
}
}- name: "key"
}- computed: false
- optional: false
}cases: [...] (4)
SwitchCase {...}
- type: "SwitchCase"
- start: 2463
- end: 2541
loc: {...}
start: {...}
- line: 114
- column: 4
}end: {...}
- line: 116
- column: 12
}
}consequent: [...] (2)
IfStatement {...}
- type: "IfStatement"
- start: 2485
- end: 2528
loc: {...}
start: {...}
- line: 115
- column: 6
}end: {...}
- line: 115
- column: 49
}
}test: BinaryExpression {...}
- type: "BinaryExpression"
- start: 2489
- end: 2509
loc: {...}
start: {...}
- line: 115
- column: 10
}end: {...}
- line: 115
- column: 30
}
}left: Identifier {...}
- type: "Identifier"
- start: 2489
- end: 2498
loc: {...}
start: {...}
- line: 115
- column: 10
}end: {...}
- line: 115
- column: 19
}
}- name: "direction"
}- operator: "!=="
right: Literal {...}
- type: "Literal"
- start: 2503
- end: 2509
loc: {...}
start: {...}
- line: 115
- column: 24
}end: {...}
- line: 115
- column: 30
}
}- value: "down"
- raw: "'down'"
}
}consequent: ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 2511
- end: 2528
loc: {...}
start: {...}
- line: 115
- column: 32
}end: {...}
- line: 115
- column: 49
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 2511
- end: 2527
loc: {...}
start: {...}
- line: 115
- column: 32
}end: {...}
- line: 115
- column: 48
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 2511
- end: 2520
loc: {...}
start: {...}
- line: 115
- column: 32
}end: {...}
- line: 115
- column: 41
}
}- name: "direction"
}right: Literal {...}
- type: "Literal"
- start: 2523
- end: 2527
loc: {...}
start: {...}
- line: 115
- column: 44
}end: {...}
- line: 115
- column: 48
}
}- value: "up"
- raw: "'up'"
}
}
}- alternate: null
} BreakStatement {...}
- type: "BreakStatement"
- start: 2535
- end: 2541
loc: {...}
start: {...}
- line: 116
- column: 6
}end: {...}
- line: 116
- column: 12
}
}- label: null
}
]test: Literal {...}
- type: "Literal"
- start: 2468
- end: 2477
loc: {...}
start: {...}
- line: 114
- column: 9
}end: {...}
- line: 114
- column: 18
}
}- value: "ArrowUp"
- raw: "'ArrowUp'"
}
} SwitchCase {...}
- type: "SwitchCase"
- start: 2546
- end: 2626
loc: {...}
start: {...}
- line: 117
- column: 4
}end: {...}
- line: 119
- column: 12
}
}consequent: [...] (2)
IfStatement {...}
- type: "IfStatement"
- start: 2570
- end: 2613
loc: {...}
start: {...}
- line: 118
- column: 6
}end: {...}
- line: 118
- column: 49
}
}test: BinaryExpression {...}
- type: "BinaryExpression"
- start: 2574
- end: 2592
loc: {...}
start: {...}
- line: 118
- column: 10
}end: {...}
- line: 118
- column: 28
}
}left: Identifier {...}
- type: "Identifier"
- start: 2574
- end: 2583
loc: {...}
start: {...}
- line: 118
- column: 10
}end: {...}
- line: 118
- column: 19
}
}- name: "direction"
}- operator: "!=="
right: Literal {...}
- type: "Literal"
- start: 2588
- end: 2592
loc: {...}
start: {...}
- line: 118
- column: 24
}end: {...}
- line: 118
- column: 28
}
}- value: "up"
- raw: "'up'"
}
}consequent: ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 2594
- end: 2613
loc: {...}
start: {...}
- line: 118
- column: 30
}end: {...}
- line: 118
- column: 49
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 2594
- end: 2612
loc: {...}
start: {...}
- line: 118
- column: 30
}end: {...}
- line: 118
- column: 48
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 2594
- end: 2603
loc: {...}
start: {...}
- line: 118
- column: 30
}end: {...}
- line: 118
- column: 39
}
}- name: "direction"
}right: Literal {...}
- type: "Literal"
- start: 2606
- end: 2612
loc: {...}
start: {...}
- line: 118
- column: 42
}end: {...}
- line: 118
- column: 48
}
}- value: "down"
- raw: "'down'"
}
}
}- alternate: null
} BreakStatement {...}
- type: "BreakStatement"
- start: 2620
- end: 2626
loc: {...}
start: {...}
- line: 119
- column: 6
}end: {...}
- line: 119
- column: 12
}
}- label: null
}
]test: Literal {...}
- type: "Literal"
- start: 2551
- end: 2562
loc: {...}
start: {...}
- line: 117
- column: 9
}end: {...}
- line: 117
- column: 20
}
}- value: "ArrowDown"
- raw: "'ArrowDown'"
}
} SwitchCase {...}
- type: "SwitchCase"
- start: 2631
- end: 2714
loc: {...}
start: {...}
- line: 120
- column: 4
}end: {...}
- line: 122
- column: 12
}
}consequent: [...] (2)
IfStatement {...}
- type: "IfStatement"
- start: 2655
- end: 2701
loc: {...}
start: {...}
- line: 121
- column: 6
}end: {...}
- line: 121
- column: 52
}
}test: BinaryExpression {...}
- type: "BinaryExpression"
- start: 2659
- end: 2680
loc: {...}
start: {...}
- line: 121
- column: 10
}end: {...}
- line: 121
- column: 31
}
}left: Identifier {...}
- type: "Identifier"
- start: 2659
- end: 2668
loc: {...}
start: {...}
- line: 121
- column: 10
}end: {...}
- line: 121
- column: 19
}
}- name: "direction"
}- operator: "!=="
right: Literal {...}
- type: "Literal"
- start: 2673
- end: 2680
loc: {...}
start: {...}
- line: 121
- column: 24
}end: {...}
- line: 121
- column: 31
}
}- value: "right"
- raw: "'right'"
}
}consequent: ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 2682
- end: 2701
loc: {...}
start: {...}
- line: 121
- column: 33
}end: {...}
- line: 121
- column: 52
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 2682
- end: 2700
loc: {...}
start: {...}
- line: 121
- column: 33
}end: {...}
- line: 121
- column: 51
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 2682
- end: 2691
loc: {...}
start: {...}
- line: 121
- column: 33
}end: {...}
- line: 121
- column: 42
}
}- name: "direction"
}right: Literal {...}
- type: "Literal"
- start: 2694
- end: 2700
loc: {...}
start: {...}
- line: 121
- column: 45
}end: {...}
- line: 121
- column: 51
}
}- value: "left"
- raw: "'left'"
}
}
}- alternate: null
} BreakStatement {...}
- type: "BreakStatement"
- start: 2708
- end: 2714
loc: {...}
start: {...}
- line: 122
- column: 6
}end: {...}
- line: 122
- column: 12
}
}- label: null
}
]test: Literal {...}
- type: "Literal"
- start: 2636
- end: 2647
loc: {...}
start: {...}
- line: 120
- column: 9
}end: {...}
- line: 120
- column: 20
}
}- value: "ArrowLeft"
- raw: "'ArrowLeft'"
}
} SwitchCase {...}
- type: "SwitchCase"
- start: 2719
- end: 2803
loc: {...}
start: {...}
- line: 123
- column: 4
}end: {...}
- line: 125
- column: 12
}
}consequent: [...] (2)
IfStatement {...}
- type: "IfStatement"
- start: 2744
- end: 2790
loc: {...}
start: {...}
- line: 124
- column: 6
}end: {...}
- line: 124
- column: 52
}
}test: BinaryExpression {...}
- type: "BinaryExpression"
- start: 2748
- end: 2768
loc: {...}
start: {...}
- line: 124
- column: 10
}end: {...}
- line: 124
- column: 30
}
}left: Identifier {...}
- type: "Identifier"
- start: 2748
- end: 2757
loc: {...}
start: {...}
- line: 124
- column: 10
}end: {...}
- line: 124
- column: 19
}
}- name: "direction"
}- operator: "!=="
right: Literal {...}
- type: "Literal"
- start: 2762
- end: 2768
loc: {...}
start: {...}
- line: 124
- column: 24
}end: {...}
- line: 124
- column: 30
}
}- value: "left"
- raw: "'left'"
}
}consequent: ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 2770
- end: 2790
loc: {...}
start: {...}
- line: 124
- column: 32
}end: {...}
- line: 124
- column: 52
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 2770
- end: 2789
loc: {...}
start: {...}
- line: 124
- column: 32
}end: {...}
- line: 124
- column: 51
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 2770
- end: 2779
loc: {...}
start: {...}
- line: 124
- column: 32
}end: {...}
- line: 124
- column: 41
}
}- name: "direction"
}right: Literal {...}
- type: "Literal"
- start: 2782
- end: 2789
loc: {...}
start: {...}
- line: 124
- column: 44
}end: {...}
- line: 124
- column: 51
}
}- value: "right"
- raw: "'right'"
}
}
}- alternate: null
} BreakStatement {...}
- type: "BreakStatement"
- start: 2797
- end: 2803
loc: {...}
start: {...}
- line: 125
- column: 6
}end: {...}
- line: 125
- column: 12
}
}- label: null
}
]test: Literal {...}
- type: "Literal"
- start: 2724
- end: 2736
loc: {...}
start: {...}
- line: 123
- column: 9
}end: {...}
- line: 123
- column: 21
}
}- value: "ArrowRight"
- raw: "'ArrowRight'"
}
}
]
}
]
}
}
]- sourceType: "module"
}attributes: [...] (1)
Attribute {...}
- type: "Attribute"
- start: 8
- end: 17
- name: "lang"
value: [...] (1)
Text {...}
- start: 14
- end: 16
- type: "Text"
- raw: "ts"
- data: "ts"
}
]
}
]
}- module: undefined
}
The AST is not public API and may change at any point in time