Built-In Language Objects

By: aathishankaran Printer Friendly Format    

The second set of objects never appears visually, but you work with them within your JavaScript code. You can call them built-in language objects because they are simply constructs of the JavaScript language. Anyone who has worked with any programming language before has worked with the following types of objects: 

String Object 

The string object represents a value you assign to a variable of an object property. JavaScript treats both assigned variables and string literals as string objects. 

Array Object 

The array object is an object representation of the traditional programming construct. An array is an ordered set of data elements, and every index number in an array contains a value. You can have as many indexes in the array as you want. 

Arrays are powerful and your JavaScript scripts can use them in a variety of ways. The following code segment shows a simple example. 

<HTML>

<HEAD>

<SCRIPT LANGUAGE = "JavaScript">

theJs = new Array(3)

theJs[l] = "Jordan"

theJs[2] = "Jared"

theJs[3] = "Justin"

document.write("<H1>The three Js are:</H1>")

document.write ("<OL>")

 for (var i = 1; i < 4; i++)

{

document.write ("<LI>" + theJs [i])

}

document.write ("</OL>")

</SCRIPT>

</HEAD>

</HTML> 

The array object is new to Netscape 3.0. Although you could work with arrays in

Netscape 2.x, you can now use the new operator to create true array objects. 

Math Object 

            The math object is used for standard mathematical calculations. Rather than using generic math functions in JavaScript, these functions are implemented as methods of the math object. Suppose you wanted to evaluate two numbers that the user entered.



Most Viewed Articles (in Java )

Latest Articles (in Java)

Comment on this tutorial