Global Object Methods

global object methods in javascript?

Explanation

Global object is defined to associate an object with globally accessible variables and functions defined in previous versions of javascript. This method can be used or referenced directly.
The below table lists the methods that are available in global objects
MethodExample CodeResultDescription
escape(string) escape("test val"); escape(string) method converts the special characters like space, colon etc of the given string in to escape sequences.
eval(expression) eval(2*(3+5)); eval method evaluates a regular expression and returns the result.
isFinite(number) isFinite(234455); isFinite(number) method returns true if the number is finite, else false.
isNaN(value) isNaN(23); isNaN function validate the argument for a number and returns true if the given value is not a number else returns false.
unescape(string) unescape("test%20val"); unescape(string); function replaces the escape sequences with original values. %20 is the escape sequence for space " ".

Thus the global object functions can be used to evaluate a regular expression (eval), validate a number (isNaN), handle escape characters, etc..

Ask Questions

Ask Question