O'Reilly logo

JavaScript® Bible, Seventh Edition by Paul Novitski, Danny Goodman, Tia Gustaff Rayl, Michael Morrison

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 24. Global Functions and Statements

IN THIS CHAPTER

  • Converting strings into object references

  • Creating URL-friendly strings

  • Adding comments to scripts

In addition to all the objects and other language constructs described in the preceding chapters of this reference part of the book, several language items need to be treated on a global scale. These items do not apply to any particular objects (or, in fact, to any object), and you can use them anywhere in a script. If you read earlier chapters, you were introduced to many of these functions and statements. This chapter serves as a convenient place to highlight these all-important items that are otherwise easily forgotten. At the end of the chapter, note the brief introduction to several objects that are built into the Windows-only versions of Internet Explorer.

This chapter begins with coverage of the following global functions and statements that are part of the core JavaScript language:

Functions

Statements

decodeURI()

// and /*...*/ (comment)

decodeURIComponent()

const

encodeURI()

var

encodeURIComponent()

 

escape()

 

eval()

 

isFinite()

 

isNaN()

 

Number()

 

parseFloat()

 

parseInt()

 

toString()

 

unescape()

 

unwatch()

 

watch()

 

Global functions are not tied to the document object model. Instead, they typically enable you to convert data from one type to another. The list of global statements is short, but a couple of them appear extensively in your scripting.

Functions

decodeURI("encodedURI")

decodeURIComponent("encodedURIComponent")

encodeURI("URIString ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required