JavaScript is an object-oriented programming language (OOP), and OOP language gives us the ability to define our own objects and variable types.
 
 
One, JavaScript string (String) object
 
1, calculate the length
 
var txt= "Hello world!"
document.write (Txt.length)
 
2, IndexOf () method
How to use IndexOf () to position the first occurrence of a specified character in a string.
var str= "Hello world!"
document.write (Str.indexof ("Hello") + "
")//0
 
3, Match () method
How to use Match () to find a specific character in a string and, if found, return the character.
var str= "Hello world!"
document.write (Str.match ("World") + "
")//world
document.write (Str.match ("AFA") + "
")//null
 
4, replace () the character in the replacement string
 
var str= "Visit microsoft!"
document.write (Str.replace (/microsoft/, "Home"))//visit home!
 
 
Second, JavaScript date (date) object
 
1, GetTime (): Calculation from 1970 to today how many years.
 
var minutes = 1000*60
var hours = minutes*60
var days = hours*24
var years = days*365
 
var d = new Date ()
var t = d.gettime ()
var y = T/years
document.write ("It ' s been:" + y + "years since 1970/01/01!")
2, setFullYear (): Set the date
var d = new Date ()
D.setfullyear (1992,10,3)//months:0~11
 
3, Getday (): Show days of the week, not just numbers.
 
var d=new Date ()
var weekday=new Array (7)
weekday[0]= "Sunday"
weekday[1]= "Monday"
weekday[2]= "Tuesday"
weekday[3]= "Wednesday"
weekday[4]= "Thursday"
weekday[5]= "Friday"
weekday[6]= "Saturday"
 
document.write ("Today is" + weekday[d.getday ())
 
4, GetDate (): Show the day of the month
var d = new Date ();
document.write (D.getdate ());
5. Set the clock
 
 
Body Load onload= "starttime ()"
 
 
Three, JavaScript array (array) objects
 
1. New array
2. For...in: Elements in the loop output array
For output
for (i=0;i
{
document.write (arr[i]+ "
");
}
For in output
for (x in arr) {
document.write (arr[x]+ "
");
}
 
3, concat (): Merge two arrays.
document.write (Arr.concat (ARR2) + "
" )
 
 4, join (): All elements of an array are composed of a string, the parameter is a join symbol 
   document.write (arr+ "
")             //a,b,c 
   document.write (arr.join () + "
")    //a,b,c 
   document.write (Arr.join ("*") + "
")   //a*b*c 
   
 5, sort (): Sorting by ASCII array 
   1) String sort 
  document.write (arr.sort () + "
")    
   2) numeric sorting 
  //Format function, a-b from small to large, b-a from big to Little 
         function Sortnumber (A, b) 
  {
   return a-b 
 & nbsp;} 
  document.write (Arr2.sort (sortnumber))