Built-In JavaScript Objects
By: aathishankaran in Javascript Tutorials on 2007-03-21
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>
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.
Add Comment
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
- Your name, rating, website address, town, country, state and comment will be publicly displayed if entered.
- Aside from the data entered into these form fields, other stored data about your comment will include:
- Your IP address (not displayed)
- The time/date of your submission (displayed)
- Your email address will not be shared. It is collected for only two reasons:
- Administrative purposes, should a need to contact you arise.
- To inform you of new comments, should you subscribe to receive notifications.
- A cookie may be set on your computer. This is used to remember your inputs. It will expire by itself.
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
- Although the administrator will attempt to moderate comments, it is impossible for every comment to have been moderated at any given time.
- You acknowledge that all comments express the views and opinions of the original author and not those of the administrator.
- You agree not to post any material which is knowingly false, obscene, hateful, threatening, harassing or invasive of a person's privacy.
- The administrator has the right to edit, move or remove any comment for any reason and without notice.
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Comments