JavaScript常用物件

2021-07-26 13:43:17 字數 736 閱讀 8155

一、window物件:全域性物件,所有物件的頂級物件

1.1 常用屬性:document,frames,location,screen......

1.2 常用方法:alert(),close(),open()....

備註:由於window物件使用十分頻繁,又是其他物件的父物件,所以在使用window物件的屬性和方法時,js允許省略window物件的名稱。

即:window.alert("");等效於alert("")

例:window.open("abc.html","abc","width=333,height=343,top=90,left=23");開啟網頁abc.html,命名為abc。

二、string物件

2.1 常用屬性:string.length

2.2 常用方法:indexof(),substr(),substring(),replace(),split()

三、date物件

dateobj=new date();

dateobj=new date(datevalue);

dateobj=new date(year,month,date.....);

常用方法:getfullyear();getmonth();getdate();getday();gethours();

常用JavaScript內建物件 一

事先總結array的幾種建立方法,第一種 var array1 new array array1 0 1 array2 1 2 第二種 var array2 new array 2 array2 0 1 array2 1 2 第三種 var array3 new array 1,2 第四種 var ...

javascript 陣列物件常用 api

concat 連線兩個或多個陣列,並返回結果 var a 1,2,3 var b a.concat 6,7 console.log a 1,2,3 console.log b 1,2,3,6,7 join str 把陣列的所有元素用str分隔,預設逗號分隔 var a 1,2,3 var b a.j...

javascript 常用內建物件 隨堂

js除錯有三種方法,如果有乙個變數m hello 請使用三種方法完成m數值的顯示 方法一,alert m 方法二,console.log m 方法三,document.title m document物件,獲取當前頁面是從哪乙個 跳轉進來的 document.referrer location物件,...