JavaScript Built-in Functions and Objects

Chapter 12 clearly states that it is not a good idea to use the eval() function in your JavaScript code. However, in certain limited areas it can be just the thing. See this blog post where a random maze is converted to a code block that could be incorporated into a Ray casting game. To see how that would look the code uses eval() to convert the generated code into a JavaScript array and then uses that to create ane display a map just like the one created in Chapter 11.

This chapter also includes a few code snippets that you might like to try out as they help explain some of the methods made available by the built-in JavaScript objects featured. You might like to try running those short code samples directly in Visual Studio Code rather than typing them into the ScratchJS tab in the Chrome browser. There is a blog post that runs through the facilities available. You would need Node.js installed and you would need to convert the alert() statements to console.log() but it is well worth trying out this option.


Read the chapter in my book Learn to Program with Games and JavaScript