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 ...

Get JavaScript® Bible, Seventh Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.