javascript對象使用介紹



字符串:


length


charAt()


substring(0, 2) (0)


indexOf('0') ('12')


lastIndexOf()


replace('', '')


split('') ('', 2)保留兩個分段






Date對象:


new Date()


toString() toLocaleString() toDateString() toTimeString() 
toLocaleDateString() toLocaleTimeString() toSource()


getDate() getDay() getMonth() getFullYear() 
getHours() getMinutes() getSeconds() getMilliseconds() getTimezoneOffset()


set...








Array對象:


new Array(,,,)


arr.length


arr[]


join()


arr.concat(arr2)


sort()


sort(compare) function compare(a, b) {return a-b;}


push(...)  pop() 尾部


shift(...) unshift() 首部


slice(0, 3) slice(0) 子數組




Math對象:


Math.PI


Math.random()






函數也是對象 Function
var add = new Function('a','b','return a+b'); alert(add(1,2));


add(1,2) 


add.call(document,1,2)


add.apply(document,[1,2])


caller屬性,可以瞭解誰調用了當前函數,只有在函數體內部caller纔有效


arguments屬性訪問傳入函數的參數


arguments.callee則是當前正在執行的函數
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章