Thursday, July 21, 2005

JavaScript buildin object

JavaScript buildin Objects:

String object:
length: a.length
charAt(pos): a.charAt(2)
charCodeAt(pos): a.charCodeAt(2)
fromCharCode(code): String.fromCharCode(99);
indexOf(searchSting, startPosition): myString.indexOf("abc"); myString.indexOf("abc", 5);
lastIndexOf(seachString, startPos);
substr(startPos, endPos); support by IE4+
substring(startPos, endPos); supported by IE3+
toLowerCase(): myString.toLowerCase();

Math object:

Math.PI
Math.abs(number);
Math.ceil(number);
Math.floor(number);
Math.round(number);
Math.randow();
Math.pows(numberToPower, power);

Number object:

toFixed(pos): myNumber.toFixed(2);

Array object:

length: myArray.length();
concat(anotherArray) join two array together: myArray1.concat(myArray2)
slice(startPos, endPos) slice out a portion of array: myArray1.slice(1, 3)
join() concatenates all the elements in an array and returns them as a string.:
myArray.join(
);
sort() sort in ascending order How about multidemential array?
reverse() sort in descending order

Date object:

create data object:
myDate1 = new Date(); current date ant time
myDate1 = new Date(949278000000) millisecond since Jan 1, 1970 at 00:00:00GMT
myDate1 = new Date("31 January 2000"); any kind of date format
myDate1 = new Date(2000, 0, 31, 15, 35, 20, 20);
getDate() : get the date of the month
getDay() : get the day of the week
getMonth(): get the month as integer
getFullYear(): get the year in four-digit number
toDateString():

setDate() : set date of the month
setMonth(): set the month of the year
setFullYear(): sets the year to the four-digit integer

getHour()
getMinutes()
getSeconds()
getMiliseconds()
toTimeString()
setHour()
setMinutes()
setSeconds()
setMilisconds()

0 Comments:

Post a Comment

<< Home