HTML and CSS Reference
In-Depth Information
Figure 7-9: A JavaScript error at the spot of the error.
In addition to highlighting errors, you can also use the console.log method to log messages and data to
the console. If you log a string it shows up as a string in the console with a matching line number called con-
sole.log . If you log something more complex than a string, the full object appears in the console and can be
inspected by clicking the arrow next to the entry.
For example, you can add the following to the playGame method from Chapter 3, “Finishing Up and Going
Mobile,” in game.js :
var playGame = function() {
var board = new GameBoard();
board.add(new PlayerShip());
board.add(new Level(level1,winGame));
console.log("Logging board");
Game.setBoard(5,new GamePoints(0));
Your console would look like Figure 7-10 when you start the game. In Figure 7-10 , the second entry, the
board , has been opened by clicking the arrow, enabling you to see all the properties it contains.
Search WWH ::

Custom Search