JS中常用的內部物件

2021-07-01 19:51:11 字數 3428 閱讀 5188

常用的js內部物件有11個:arraybooleandatefunctionglobalmathnumberobjectregexperror以及string

array物件

提供對建立任何資料型別的陣列的支援。

arrayobj = new array()

arrayobj = new array([size])

arrayobj = new array([element0[, element1[, ...[, elementn]]]])引數

arrayobj

必選項。要賦值為 array 物件的變數名。

size

可選項。可選項陣列的大小。由於陣列的下標是從零開始,建立的元素的下標將從零到 size -1。

element0,...,elementn

可選項。要放到陣列中的元素。這將建立具有 n + 1 個元素的長度為 n + 1 的陣列。使用該語法時必須有乙個以上元素。

屬性constructor 屬性 | length 屬性 | prototype 屬性 方法

concat 方法 | join 方法 | pop 方法 | push 方法 | reverse 方法 | shift 方法 | slice 方法 | sort 方法 | splice 方法 | tolocalestring 方法 | tostring 方法 | unshift 方法 | valueof 方法

string物件

可用於處理或格式化文字字串以及確定和定位字串中的子字串。

語法

newstring = new string(["stringliteral"])引數

newstring

必選項。要賦值為 string 物件的變數名。

stringliteral

可選項。任意 unicode 字元群。

屬性constructor 屬性 | length 屬性 | prototype 屬性 方法

anchor 方法 | big 方法 | blink 方法 | bold 方法 | charat 方法 | charcodeat 方法 | concat 方法 | fixed 方法 | fontcolor 方法 | fontsize 方法 | fromcharcode 方法 | indexof 方法 | italics 方法 | lastindexof 方法 | link 方法 | match 方法 | replace 方法 | search 方法 | slice 方法 | small 方法 | split 方法 | strike 方法 | sub 方法 | substr 方法 | substring 方法 | sup 方法 | tolowercase 方法 | touppercase 方法 | tostring 方法 | valueof 方法

math 物件

是乙個固有物件,提供基本數學函式和常數。

說明 math 物件不能用 new 運算子建立,如果試圖這樣做則給出錯誤。該物件在裝載指令碼引擎時由該引擎建立。其所有方法和屬性在指令碼中總是可用。 屬性

e 屬性 | ln2 屬性 | ln10 屬性 | log2e 屬性 | log10e 屬性 | pi 屬性 | sqrt1_2 屬性 | sqrt2 屬性方法

abs 方法 | acos 方法 | asin 方法 | atan 方法 | atan2 方法 | ceil 方法 | cos 方法 | exp 方法 | floor 方法 | log 方法 | max 方法 | min 方法 | pow 方法 | random 方法 | round 方法 | sin 方法 | sqrt 方法 | tan 方法

date 物件

啟用基本儲存器並取得日期和時間。

dateobj = new date()

dateobj = new date(dateval)

dateobj = new date(year, month, date[, hours[, minutes[, seconds[,ms]]]])

屬性

constructor 屬性 | prototype 屬性方法

getdate 方法 | getday 方法 | getfullyear 方法 | gethours 方法 | getmilliseconds 方法 | getminutes 方法 | getmonth 方法 | getseconds 方法 | gettime 方法 | gettimezoneoffset 方法 | getutcdate 方法 | getutcday 方法 | getutcfullyear 方法 | getutchours 方法 | getutcmilliseconds 方法 | getutcminutes 方法 | getutcmonth 方法 | getutcseconds 方法 | getvardate 方法 | getyear 方法 | setdate 方法 | setfullyear 方法 | sethours 方法 | setmilliseconds 方法 | setminutes 方法 | setmonth 方法 | setseconds 方法 | settime 方法 | setutcdate 方法 | setutcfullyear 方法 | setutchours 方法 | setutcmilliseconds 方法 | setutcminutes 方法 | setutcmonth 方法 | setutcseconds 方法 | setyear 方法 | togmtstring 方法 | tolocalestring 方法 | toutcstring 方法 | tostring 方法 | valueof 方法 | parse 方法 | utc 方法

number 物件

代表數值資料型別和提供數值常數的物件。

numobj = new number(value)屬性

max_value 屬性 | min_value 屬性 | nan 屬性 | negative_infinity 屬性 | positive_infinity 屬性 | constructor 屬性 | prototype 屬性 方法

tolocalestring 方法 | tostring 方法 | valueof 方法

這個只是js   api中的一部分 ,需要的話可以下乙個api好好研究。

js 中常用的總結

1 變數宣告 宣告變數 var a 給變數賦值 a 100 2 一些常用的用法 typeof 返回物件的資料型別,undefined被轉化為nan var num 12abc 型別轉化 轉化為整形,從資料位開始,一直到非資料位結束 var int parseint num document.writ...

Js 中常用方法

一 獲取唯一值 2014 12 23 1 function newguid 7return guid 8 view code bttup click function beforesend function complete function success function data,status...

js中常用的物件 String的屬性和方法

今天說一下,js中常用的內建物件 string物件 它有以下幾個常用的屬性 length prototype 有以下幾個常用的方法 parseint 轉換為數字 parsefloat 轉換為數字,支援更大的數字,支援小數 charat 返回在指定位置的字元 charcodeat 返回在指定的位置的字...