Javascript Globals reference

Javascript build-in global object reference.

Global Methods:

Syntax: decodeURI(URI)
Decodes a URI which has been encoded with encodeURI.

Is primarily intended for use with query string that is added to a Web address to make sure it is not misinterpreted as some of the other parts of the address.

Return value: A decoded string
URI: URI string to be decoded.
An example of using the decodeURI() :
<script type="text/javascript">
var uri ="index.php?page=What is Java%";
// encoding the uri
var encodedUri=encodeURI(uri);
document.write(encodedUri+"<br>");
// decoding the returned uri from encoding
document.write(decodeURI(encodedUri)+"<br>");
// codes that are not encoded
encodedUri=encodeURI("-_.!~*'();/?:@&=+$,#");
document.write(encodedUri+"<br>");
// decoding the returned uri from encoding
document.write(decodeURI(encodedUri)+"<br>");
</script>

Global Properties:

Infinity : A numeric value that represents positive infinity.
NaN : The not-a-number value.
undefined : The undefined value. Appear for a variable that has been declared but never had a value assigned to it or any value type that does not exist.

Global Objects:

To create an array: new Array([param])
You uses the new keyword to create an array object.
To use as a function: Array([param])
When the Array object is used as a function the return will be an array as well.
param: The param argument is optional. If it is absent an empty array is returned.

If the param argument is present it can be one of the following:

  1. A number indicating the size of the array you want to create.
  2. A comma separated list of data values the array shall contain.
An example of using the new Array(param):
<script type="text/javascript">
var stringArr= new Array("Boolean","Math","Number","Object","String");
document.write("String array: "+stringArr+"<br>");
var arrObj= new Array(10);
document.write("Array with 10 undefined elements: "+arrObj+"<br>");
</script>

© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the correctness in the pages or source codes.
The risk of using this web-site pages or any program codes from this website is entirely at the individual user.