2022年JavaScript内置对象属性及方法大全3.docx
名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -JavaScript 内置对象属性及方法大全属性 1: constructor 所建立对象的函数参考prototype 能够为对象加入的属性和方法方法 43: getDay 返回一周中的第几天 0-6 getYear 返回年份 .2000 年以前为 2 位,2000包含 以后为 4 位getFullYear 返回完整的 4 位年份数getMonth 返回月份数 0-11 getDate 返回日 1-31 getHours 返回小时数 0-23 getMinutes 返回分钟 0-59 getSeconds 返回秒数 0-59 getMilliseconds 返回毫秒 0-999 getUTCDay 依据国际时间来得到现在是星期几 0-6 getUTCFullYear 依据国际时间来得到完整的年份getUTCMonth 依据国际时间来得到月份 0-11 getUTCDate 依据国际时间来得到日 1-31 getUTCHours 依据国际时间来得到小时 0-23 getUTCMinutes 依据国际时间来返回分钟 0-59 getUTCSeconds 依据国际时间来返回秒 0-59 getUTCMilliseconds 依据国际时间来返回毫秒 0-999 getTime 返回从 1970 年 1 月 1 号 0:0:0 到现在一共花去的毫秒数getTimezoneoffset 返回时区偏差值 ,即格林威治平均时间 GMT 与运行脚本的运算机所处时区设置之间相差的分钟数 parsedateString 返回在 Date 字符串中自从 1970 年 1 月 1 日 00:00:00 以来的毫秒数setYearyearInt 设置年份 .2 位数或 4 位数setFullYearyearInt 设置年份 .4 位数setMonthmonthInt 设置月份 0-11 setDatedateInt 设置日 1-31 setHourshourInt 设置小时数 0-23 setMinutesminInt 设置分钟数 0-59 setSecondssecInt 设置秒数 0-59 setMillisecondsmilliInt 设置毫秒 0-999 setUTCFullYearyearInt 依据国际时间来设置年份setUTCMonthmonthInt 依据国际时间来设置月 0-11 setUTCDatedateInt 依据国际时间来设置日 1-31 setUTCHourshourInt 依据国际时间来设置小时setUTCMinutesminInt 依据国际时间来设置分钟setUTCSecondssecInt 依据国际时间来设置秒setUTCMillisecondsmilliInt 依据国际时间来设置毫秒setTimetimeInt 设置从 1970 年 1 月 1 日开头的时间 .毫秒数toGMTString 依据格林威治时间将 Date 对象的日期 一个数值 转变成一个 GMT 时间字符串 ,如:Weds,15 June l997 14:02:02 GMT 细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 1 页,共 7 页 - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -toUTCString 依据通用时间将一个Date 对象的日期转换为一个字符串toLocaleString 把 Date 对象的日期 一个数值 转变成一个字符串,使用所在运算机上配置使用的特定日期格式toSource 显示对象的源代码toString 将日期对象转换为字符串UTCyyyy, mm, dd, hh, mm, ss, msec返回从格林威治标准时间到指定时间的差距 ,单位为毫秒valueOf 返回日期对象的原始值2.Math 属性 : constructor 所建立对象的函数参考prototype 能够为对象加入的属性和方法E 欧拉常量 ,自然对数的底 约等于 2.718 LN2 2 的自然对数 约等于 0.693 LN10 10 的自然对数 约等于 2.302 LOG2E 以 2 为底的 e 的对数 .约等于 1.442 LOG10E 以 10 为底的 e 的对数 约等于 0.434 PI 的值 约等于 3.14159 SQRT1_2 1/20.5 的平方根 即 l 除以 2 的平方根 ,约等于 o.707 SQRT2 2 的平方根 约等于 1.414 方法 : absx 返回数字的肯定值acosx 返回数字的反余弦值asinx 返回数字的反正弦值atanx 返回位于 -PI/2 和 PI/2 的反正切值atan2y,x 返回( x,y)位于-PI 到 PI 之间的角度ceilx 返回 x 四舍五入后的最大整数cosx 返回一个数字的余弦值expx 返回 Ex 值floorx 返回 x 四舍五入后的最小整数logx 返回底数为 E 的自然对数maxx,y 返回 x 和 y 之间较大的数minx,y 返回 x 和 y 之间较小的数powx,y 返回 yx 的值random 返回位于 0 到 1 之间的随机函数roundx 四舍五入后取整sinx 返回数字的正弦值sqrtx 返回数字的平方根tanx 返回一个角度的正切值toSource 显示对象的源代码valueOf 返回数学对象的原始值3.Number 属性 : MAX_V ALUE The largest possible value a number in JavaScript can have 第 2 页,共 7 页 细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -1.7976931348623157E+308 MIN_V ALUE The smallest possible value a number in JavaScript can have 5E-324 NaN Equal to a value that is not a number. NEGATIVE_INFINITY A value that is less than MIN_V ALUE. ALUE. POSOTIVE_INFINITY A value that is greater than MAX_V prototype A static property of the Number object 方法 : toString Returns a string representing the specified object valueOf 返回数学对象的原始值 4.Boolean 属性 : constructor 所建立对象的函数参考 prototype 能够为对象加入的属性和方法 方法 : toSource 显示对象的源代码,并且返回结果toString 将布尔值转换为字符串valueOf 返回布尔对象的原始值5.String 属性 : constructor 所建立对象的函数参考 prototype 能够为对象加入的属性和方法 length 返回字符串的字符长度 方法 20: anchor"name" 用来把字符串转换为HTML 锚点标记内 <A NAME=> big 把字符串中的文本变成大字体 <BIG> blink 把字符串中的文本变成闪耀字体 <BLINK> bold 把字符串中的文本变成黑字体 <B> fixed 把字符串中的文本变成固定间距字体 ,即电报形式 <TT> fontcolorcolor 设置字符串中文本的颜色 <FONT COLOR=> Fontsizesize 把字符串中的文本变成指定大小 <FONTSIZE=> italics 把字符串中的文本变成斜字体 <I> Linkurl 用来把字符串转换-HTML 链接标记中 <A HREF=> small 把字符串中的文本变成小字体 <SMALL> strike 把字符串中的文本变成划掉字体 <STRIKE> sub 把字符串中的文本变成下标 subscript 字体 SUB> sup 把字符串中的文本变成上标 superscript 字体 <SUP> charAtindex 返回指定索引处的字符charCodeAtindex 返回一个整数 ,该整数表示String 对象中指定位置处的字符的Unicode 编码concatstring2 连接两条或多条字符串fromCharCodenum1, num2, , numN 猎取指定的Unicode 值并返回字符串indexOfsearchString, startIndex 返回字符串中第一个显现指定字符串的位置 lastlndexOfsearchString, startIndex 返回字符串中最终一个显现指定字符串的位置 matchregex 在字符串中查找指定值replaceregex, newString 将字符串中的某些字符替换成其它字符细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 3 页,共 7 页 - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -searchregex 针对某执行值对字符串进行查找 slicestartIndex, endIndex 将部分字符抽出并在新的字符串中返回剩余部分 splitdelimiter 将字符串安排为数组 substrstartIndex, length 从 startIndex 取,取 length 个字符 substringstartIndex, endIndex 从 startIndex 和 endIndex 之间的字符 ,不包括 endIndex toLowerCase 把字符串中的文本变成小写 toUpperCase 把字符串中的文本变成大写 toSource 显示对象的源代码 valueOf 返回字符串对象的原始值 6.Array 属性 : constructor 所建立对象的函数参考 prototype 能够为对象加入的属性和方法index For an array created by a regular expression match, the zero-based index of the match in the string. input For an array created by a regular expression match, reflects the original string against which the regular expression was matched. length 猎取数组元素的个数,即最大下标加1 方法 13: concatarray1,arrayn将两个或两个以上的数组值连接起来 ,合并后返回结果 joinstring 将数组中元素合并为字符串 ,string 为分隔符 .如省略参数就直接合并 ,不再分隔 pop 移除数组中的最终一个元素并返回该元素pushvalue 在数组的末尾加上一个或多个元素,并且返回新的数组长度值reverse 颠倒数组中元素的次序 ,反向排列shift 移除数组中的第一个元素并返回该元素slicestart, deleteCount, item1, item2,.,itemN 返从一个数组中移除一个或多个元素 ,如果必要 ,在所移除元素的位置上插入新元素 ,返回所移除的元素sortcompare Function 在未指定排序号的情形下 ,依据元素的字母次序排列 ,假如不是字符串类型就转换成字符串再排序 ,返回排序后的数组splice 为数组删除并添加新的元素toSource 显示对象的源代码toString 将数组全部元素返回一个字符串 ,其间用逗号分隔unshiftvalue 为数组的开头部分加上一个或多个元素valueOf 返回数组对象的原始值7.RegExp 属性 : $1, ., $9 Parenthesized substring matches, if any. $_ See input. $* See multiline. $& See lastMatch. $+ See lastParen. $ See leftContext. $' See rightContext. ,并且返回该数组的新长度global Whether or not to test the regular expression against all possible matches in a string, 第 4 页,共 7 页 细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -or only against the first. ignoreCase Whether or not to ignore case while attempting a match in a string. input The string against which a regular expression is matched. lastIndex The index at which to start the next match. lastMatch The last matched characters. lastParen The last parenthesized substring match, if any. leftContext The substring preceding the most recent match. multiline Whether or not to search in strings across multiple lines. rightContext The substring following the most recent match. source The text of the pattern. 方法 : compile Compiles a regular expression object. exec Executes a search for a match in its string parameter. test Tests for a match in its string parameter 8.Function 属性 : arguments An array corresponding to the arguments passed to a function. arity Indicates the number of arguments expected by the function. caller Specifies which function called the current function. prototype Allows the addition of properties to a Function object. 方法 : toString Returns a string representing the specified object. 9.Object 属性 : constructor Specifies the function that creates an object's prototype. prototype Allows the addition of properties to all objects. 方法 : eval Evaluates a string of JavaScript code in the context of the specified object. toString Returns a string representing the specified object. unwatch Removes a watchpoint from a 属性源 the object. valueOf Returns the primitive value of the specified object. watch Adds a watchpoint to a 属性源 the object. 10.全局属性 : Infinity 指定一个正负无穷大的数值NaN 指定一个“ 非数字”值undefined 指定一个未被赋值的变量方法 : decodeURI 为加密的 URI 进行解码decodeURIComponent 为加密的 URI 组件解码encodeURI 将字符串加密为URI 第 5 页,共 7 页 - - - - - - - - - encodeURIComponent 将字符串加密为URI 组件escapestring 加密一个字符串unescape 使用 escape对一个字符串进行解码细心整理归纳 精选学习资料 - - - - - - - - - - - - - - -名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -evalstring 判定一个字符串并将其以脚本代码的形式执行isFinitenumber 检测一个值是否为一个有限数字 ,返回 True 或 False isNaNstring 检测一个值是否不是一个有限数字Number 将一个对象的值转换为一个数字parseFloatstring 将一个字符串解析为一个浮点数字parseIntstring 将一个字符串解析为一个整数 ,不是四舍五入操作 ,而是切尾Stringobject 将一个对象值转换为一个字符串numberobject 11.大事属性 : a.窗口大事 ,只在 body 和 frameset 元素中才有效onload 页面或图片加载完成时onunload 用户离开页面时b.表单元素大事 ,在表单元素中才有效onchange 框内容转变时onsubmit 点击提交按钮时onreset 重新点击鼠标按键时onselect 文本被挑选时onblur 元素失去焦点时onfocus 当元素猎取焦点时c.键盘大事 ,在 base,bdo,br,frame,frameset,head,html,iframe,meta,param,script,style,title 元素里都无效onkeydown 按下键盘按键时onkeypress 按下或按住键盘按键时onkeyup 放开键盘按键时d.在 base,bdo,br,frame,frameset,head,html,iframe,meta,param,script,style,title 元素里都无效onclick 鼠标点击一个对象时ondblclick 鼠标双击一个对象时onmousedown 鼠标被按下时onmousemove 鼠标被移动时onmouseout 鼠标离开元素时onmouseover 鼠标经过元素时onmouseup 释放鼠标按键时e.其他onresize 当窗口或框架被重新定义尺寸时onabort 图片下载被打断时onerror 当加载文档或图片时发生错误时自定义对象 :有初始化对象和定义构造函数的对象两种方法a:初始化对象例如: 对象 = 属性 1:值 1;属性 2:值 2;.属性 n:值 n 留意 :每个属性 /值对之间用分号隔开;b: 定义构造函数的对象例如 : function 函数名 属性 1, 属性 2,.属性 N 细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - 第 6 页,共 7 页 - - - - - - - - - 名师归纳总结 精品学习资料 - - - - - - - - - - - - - - -this.属性 1=属性值 1; this.属性 2=属性值 2; this.属性 n=属性值 n; this.方法名 1=函数名 1; this.方法名 2=函数名 2; 留意:方法名和函数名可以同名,但是在方法调用函数前,函数必需已经定义好,否就会出错 第 7 页,共 7 页 为自定义的函数创建新的实例一样是使用new 语句;细心整理归纳 精选学习资料 - - - - - - - - - - - - - - - - - - - - - - - -