article

language object - "the global object"

[WHAT]

  1. ] you don't create "the global object", it is created automatically,
    1. ] for each new window in your web site/application
  2. ] it contains
    1. ] the properties and methods(functions) listed below
    2. ] AND any 'globally scoped' objects that "your code" contains 
  3. ] "the global object" is "global" in "scope"
    1. ] so you can access it's(properties/methods) from anywhere in your
  4. ] do not confuse this with the ...
    1. ] the "Object object" -
    2. ] "global scope" - which refers to 'any object variables' that you can access from anywhere in your code.

[WHY]

  1. [properties]
    1. ] undefined -
    2. ] Infinity -
    3. ] Nan -
    4. ] Null -
  2. [methods]
    1. ] eval()
    2. ] uneval()
    3. ] isFinite()
    4. ] isNaN()
    5. ] parseFloat()
    6. ] parseInt()
    7. ] decodeURI()
    8. ] decodeURIComponent()
    9. ] encodeURI()
    10. ] encodeURIComponent()
    11. ] escape()
    12. ] unescape()

[WHERE]

  1. ] 'the global object' exists
    1. ] on every 'web page' (aka window) that you use

[WHEN]

  1. ]  you want to use methods that belong to 'the global object' like ...  
    1. ] encoding and decoding url's
  2. ] you want to create an object variable that is available from anywhere in your code
    1. ]

[EXAMPLE]

  1. ] var numericValue =parseInt("66"); // would return the numberic value of 66 from the string value of "66".

[HOW-TO]

  1. ] check for undefined
  2. ] decodeURI
  3. ] encodeURI

[REFERENCE]

  1. ] http://www.w3schools.com/jsref/jsref_obj_global.asp 
  2. ] https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects
  3. ] understanding global - the global object and variables with global scope
Details Photos Edit more

Details

ID: 2706

NAME: Global

DESCRIPTION: ]javascript languages NATIVE 'global' object

AUTHOR: article.author/s

EDITOR: article.editor/s

PUBLISHER: article.publisher/s

STATUS: Write

PRIORITY: -5

OWNER ID: 75

Content Photos Edit more

photos

page_photo

actions

Email Email-Owner SMS and