edit-article
Home
Up
Delete
Article Name:
Article Description:
]javascript languages NATIVE 'global' object
Chapter ID/Name:
Status:
Write
Writing
Written
Add Photo:
Owner ID:
Content:
use HTML
Edit Content
<h1 style="text-align: center;">language object - "the global object"</h1> <h2>[WHAT]</h2> <ol> <li><strong>] you don't create "the global object", it is created automatically,</strong></li> <ol> <li>] for each new window in your web site/application</li> </ol> <li><strong>] it contains</strong></li> <ol> <li>] the properties and methods(functions) listed below</li> <li>] AND any 'globally scoped' objects that "your code" contains </li> </ol> <li><strong>] "the global object" is "global" in "scope"</strong></li> <ol> <li>] so you can access it's(properties/methods) from anywhere in your</li> </ol> <li><strong>] do not confuse this with the ...</strong></li> <ol> <li>] the "Object object" -</li> <li>] "global scope" - which refers to 'any object variables' that you can access from anywhere in your code.</li> </ol></ol> <h2>[WHY]</h2> <ol> <li><strong>[properties]</strong></li> <ol> <li>] undefined -</li> <li>] Infinity -</li> <li>] Nan -</li> <li>] Null -</li> </ol> <li><strong>[methods] </strong></li> <ol> <li>] <a title="The eval() method evaluates JavaScript code represented as a string." href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval" target="_blank"><code>eval()</code></a></li> <li>] <a title="The uneval() method creates an string representation of the source code of an Object." href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/uneval" target="_blank"><code>uneval()</code></a></li> <li>] <a title="The global isFinite() function determines whether the passed value is a finite number. If needed, the parameter is first converted to a number." href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isFinite" target="_blank"><code>isFinite()</code></a></li> <li>] <a title="The isNaN() function determines whether a value is NaN or not. Note: coercion inside the isNaN function has interesting rules; you may alternatively want to use Number.isNaN(), as defined in ECMAScript 6, or you can use typeof to determine if the value is Not-A-Number." href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN" target="_blank"><code>isNaN()</code></a></li> <li>] <a title="The parseFloat() function parses a string argument and returns a floating point number." href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseFloat" target="_blank"><code>parseFloat()</code></a></li> <li>] <a title="The parseInt() function parses a string argument and returns an integer of the specified radix (the base in mathematical numeral systems)." href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt" target="_blank"><code>parseInt()</code></a></li> <li>] <a title="The decodeURI() function decodes a Uniform Resource Identifier (URI) previously created by encodeURI or by a similar routine." href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI" target="_blank"><code>decodeURI()</code></a></li> <li>] <a title="The decodeURIComponent() method decodes a Uniform Resource Identifier (URI) component previously created by encodeURIComponent or by a similar routine." href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent" target="_blank"><code>decodeURIComponent()</code></a></li> <li>] <a title="The encodeURI() method encodes a Uniform Resource Identifier (URI) by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two "surrogate" characters)." href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI" target="_blank"><code>encodeURI()</code></a></li> <li>] <a title="The encodeURIComponent() method encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two "surrogate" characters)." href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent" target="_blank"><code>encodeURIComponent()</code></a></li> <li>] <a title="The deprecated escape() method computes a new string in which certain characters have been replaced by a hexadecimal escape sequence. Use encodeURI or encodeURIComponent instead." href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/escape" target="_blank"><code>escape()</code></a></li> <li>] <a title="The deprecated unescape() method computes a new string in which hexadecimal escape sequences are replaced with the character that it represents. The escape sequences might be introduced by a function like escape. Because unescape is deprecated, use decodeURI or decodeURIComponent instead." href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape" target="_blank"><code>unescape()</code></a></li> </ol></ol> <h2>[WHERE]</h2> <ol> <li><strong>] 'the global object' exists</strong></li> <ol> <li>] on every 'web page' (aka window) that you use</li> </ol></ol> <h2>[WHEN]</h2> <ol> <li><strong>] you want to use methods that belong to 'the global object' like ... </strong></li> <ol> <li>] encoding and decoding url's</li> </ol> <li><strong>] you want to create an object variable that is available from anywhere in your code</strong></li> <ol> <li>]</li> </ol></ol> <h2>[EXAMPLE]</h2> <ol> <li>] var numericValue =parseInt("66"); // would return the numberic value of 66 from the string value of "66".</li> </ol> <h2>[HOW-TO]</h2> <ol> <li>] check for undefined</li> <li>] decodeURI</li> <li>] encodeURI</li> </ol> <h2>[REFERENCE]</h2> <ol> <li>] <a href="http://www.w3schools.com/jsref/jsref_obj_global.asp">http://www.w3schools.com/jsref/jsref_obj_global.asp</a> </li> <li>] <a href="https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects" target="_blank">https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects</a></li> <li>] <a href="/view/article?id=2692" target="_blank">understanding global</a> - the global object and variables with global scope</li> </ol>