JavaScript is an Object Oriented Programming Language. It is completely centered around objects. May if you are newer you have question about What is an object? so the very short answer is everything is object.
In the context of a web page, a JavaScript object is any scriptable HTML element – that is any HTML element within a document that may be accessed through the JavaScript language. Scriptable HTML elements are associated with the Document Object Model, also known as the DOM.
Object:
In JavaScript, you interact with the browser throught the use of built in objects; these objects exist already, and can be accessed from your JavaScript code by name. The built-in objects are Date, Math, String, Array, and Object. Each is used in a unique and not-quite-consistent way. Objects have properties, which you can think of as characteristics of an object. Here are the four most commoly used objects:
1. The String Object:
The String object is used to manipulate a stored piece of text. The String object of JavaScript allows you to perform manipulations on a stored piece of text, such as extracting a substring, searching for the occurrence of a certain character within it etc. General method of using String Object is to declare a variable and assign a string, in other words a text to the variable.
String Object Properties:
length – The number of characters in the string. (# characters)
prototype – For creating more properties
String Object Methods for HTML Formatting:
|
Method Name |
Returned Value |
| anchor | <A NAME=”anchortext”>foo</A> |
| big | <BIG>foo</BIG> |
| blink | <BLINK>foo</BLINK> |
| bold | <B>foo</B> |
| fixed | <TT>foo</TT> |
| fontcolor | <FONT COLOR=”green”>foo</ |
| fontsize | <FONT SIZE=”-1″>foo</FONT> |
| italics | <I>foo</I> |
| link | <A HREF=”linktext”>foo</A> |
| small | <SMALL>foo</SMALL> |
| strike | <STRIKE>foo</STRIKE> |
| sub | <SUB>foo</SUB> |
| sup | <SUP>foo</SUP> |
| toLowerCase | uppercase |
| toUpperCase | UPPERCASE |
2. The Math Object :
The Math object allows you to perform mathematical tasks. The JavaScript math object can be invoked without creating an instance of it. But unlike the String and the Date object which requires defining the object, Math object need not be defined. So in conclusion The Math object of JavaScript allows you to perform certain calculations by using method functions of the Math object.
JavaScript Math Object Properties:
E – Euler’s constant
LN2 – Natural log of 2
LN10 – Natural log of 10
LOG2E – Base 2 logarithm of E.
LOG10E – Base 10 logarithm of E.
PI – Value of Pi
SQRT1_2 – Square root of 1/2.
SQRT2 – Square root of 2
Math Object Method:
|
Method |
Description |
| abs(a) | Supplies the absolute value of a number |
| acos(a) | Supplies the arccosine of a number |
| asin(a) | Supplies the arcsine of a number |
| atan(a) | Supplies the arctangent of a as a numeric value between -PI/2 and PI/2 radians |
| atan2(a,b) | Supplies the angle theta of a point as a numeric value between -PI and PI radians |
| ceil(a) | Supplies the value of a number rounded up to the nearest number |
| cos(a) | Supplies the cosine of a number |
| exp(a) | Supplies the exponential value of a number |
| floor(a) | Supplies the value of a number rounded down to the nearest number |
| log(a) | Supplies the logarithm of a number |
| max(a,b) | Supplies the number with the highest value |
| min(a,b) | Supplies the number with the lowest value |
| pow(a,b) | Supplies the value of one number (a) to the power of the second number (b) |
| random( ) | Supplies a random number between 0 and 9 |
| round(a) | Supplies a number rounded to the nearest number |
| sin(a) | Supplies the sine of a number |
| sqrt(a) | Supplies the square root of a number |
| tan(a) | Supplies the tangent of an angle |
| toSource(a) | Refers to the source code of an object |
| valueOf( ) | Supplies the primitive value of a math object |
3. The Date Object:
The Date object is used to work with dates and times. Generally in web page the Date object provides information about the current date and time on the client’s machine. The Date object is similar to the String object in that you create new instances of the object when you assign it to a variable. It differs from the String object in that you use a statement called new to create it.
JavaScript Date Object Properties:
constructor – Returns a reference to the Date function that created the object .
prototype – Allows you to add properties and methods to the object.
Instantiating a date object:
new Date()
new Date(milliseconds)
new Date(dateString)
new Date(year, month, day, hours, minutes, seconds, milliseconds)
JavaScript Date Object Properties:
| Method | Description |
| Date() | Returns today’s date and time |
| getDate() | Returns the day of the month from a Date object (from 1-31) |
| getDay() | Returns the day of the week from a Date object (from 0-6) |
| getMonth() | Returns the month from a Date object (from 0-11) |
| getFullYear() | Returns the year, as a four-digit number, from a Date object |
| getYear() | Returns the year, as a two-digit or a four-digit number, from a Date object. Use getFullYear() instead !! |
| getHours() | Returns the hour of a Date object (from 0-23) |
| getMinutes() | Returns the minutes of a Date object (from 0-59) |
| getSeconds() | Returns the seconds of a Date object (from 0-59) |
| getMilliseconds() | Returns the milliseconds of a Date object (from 0-999) |
| getTime() | Returns the number of milliseconds since midnight Jan 1, 1970 |
| getTimezoneOffset() | Returns the difference in minutes between local time and Greenwich Mean Time (GMT) |
| getUTCDate() | Returns the day of the month from a Date object according to universal time (from 1-31) |
| getUTCDay() | Returns the day of the week from a Date object according to universal time (from 0-6) |
| getUTCMonth() | Returns the month from a Date object according to universal time (from 0-11) |
| getUTCFullYear() | Returns the four-digit year from a Date object according to universal time |
| getUTCHours() | Returns the hour of a Date object according to universal time (from 0-23) |
| getUTCMinutes() | Returns the minutes of a Date object according to universal time (from 0-59) |
| getUTCSeconds() | Returns the seconds of a Date object according to universal time (from 0-59) |
| getUTCMilliseconds() | Returns the milliseconds of a Date object according to universal time (from 0-999) |
| parse() | Takes a date string and returns the number of milliseconds since midnight of January 1, 1970 |
| setDate() | Sets the day of the month in a Date object (from 1-31) |
| setMonth() | Sets the month in a Date object (from 0-11) |
| setFullYear() | Sets the year in a Date object (four digits) |
| setYear() | Sets the year in the Date object (two or four digits). Use setFullYear() instead !! |
| setHours() | Sets the hour in a Date object (from 0-23) |
| setMinutes() | Set the minutes in a Date object (from 0-59) |
| setSeconds() | Sets the seconds in a Date object (from 0-59) |
| setMilliseconds() | Sets the milliseconds in a Date object (from 0-999) |
| setTime() | Calculates a date and time by adding or subtracting a specified number of milliseconds to/from midnight January 1, 1970 |
| setUTCDate() | Sets the day of the month in a Date object according to universal time (from 1-31) |
| setUTCMonth() | Sets the month in a Date object according to universal time (from 0-11) |
| setUTCFullYear() | Sets the year in a Date object according to universal time (four digits) |
| setUTCHours() | Sets the hour in a Date object according to universal time (from 0-23) |
| setUTCMinutes() | Set the minutes in a Date object according to universal time (from 0-59) |
| setUTCSeconds() | Set the seconds in a Date object according to universal time (from 0-59) |
| setUTCMilliseconds() | Sets the milliseconds in a Date object according to universal time (from 0-999) |
| toSource() | Represents the source code of an object |
| toString() | Converts a Date object to a string |
| toGMTString() | Converts a Date object, according to Greenwich time, to a string. Use toUTCString() instead !! |
| toUTCString() | Converts a Date object, according to universal time, to a string |
| toLocaleString() | Converts a Date object, according to local time, to a string |
| UTC() | Takes a date and returns the number of milliseconds since midnight of January 1, 1970 according to universal time |
| valueOf() | Returns the primitive value of a Date object |
JavaScript Object, Method, propeties for Ajax:
- history: Represents the list of URLs that the browser had already been to.
- window: Represents the browser itself.
- XMLHttpRequest: The object that you use in Ajax to communicate with the server.
In JavaScript, Objects have methods and properties. A method is a chunk of code built into the object that performs some action. For example: you use the document object’s write method, which you access as document.write, to write to the document (in the current web page).
- document.write: Lets you write text to the current web page
- history.go: Moves the browser to a page in the browser’s history
- window.open: Opens a new browser window
Properties, on the other hand, are just settings that you can place data into. JavaScript properties often take their names from the attributes of HTML elements, such as the bgcolor attribute of the <body> element.
- document.bgcolor: Holds the background color of the current page.
- document.fgcolor: Holds the foreground color of the current page.
- document.lastmodified: Holds the data the page was last modified.
- document.title: Holds the title of the page
- location.hostname: Holds the name of the page’s host.
- navigator.appName: Holds the type of the browser

RSS Feeds
Feed Comment 




Leave Your Comments Below