zoukankan      html  css  js  c++  java
  • javascript内置函数

    1.Date:日期函数
    属性(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)取运转足原的盘算机所处时区设置之间相差的分钟数)
    parse(dateString) 返回正在Date字符串中自从1970年1月1日00:00:00以来的毫秒数
    setYear(yearInt) 设置年份.2位数或4位数
    setFullYear(yearInt)设置年份.4位数
    setMonth(monthInt) 设放月份(0-11)
    setDate(dateInt) 设置日(1-31)
    setHours(hourInt) 设置小时数(0-23)
    setMinutes(minInt) 设置分钟数(0-59)
    setSeconds(secInt) 设放秒数(0-59)
    setMilliseconds(milliInt) 设放毫秒(0-999)
    setUTCFullYear(yearInt) 依据国际时间来设置年份
    setUTCMonth(monthInt) 依据国际时间来设置月(0-11)
    setUTCDate(dateInt) 依据国际时间来设置日(1-31)
    setUTCHours(hourInt) 依据国际时间来设置小时
    setUTCMinutes(minInt) 依据国际时间来设置分钟
    setUTCSeconds(secInt) 依据国际时间来设置秒
    setUTCMilliseconds(milliInt)根据邦际时间来设置毫秒
    setTime(timeInt) 设置自1970年1月1日开端的时间.毫秒数
    toGMTString() 依据格林威乱时光将Date对于象的日期(一个数值)改变成一个GMT光阴字符串,如:Weds,15 June l997 14:02:02 GMT
    toUTCString() 依据通用时间将一个Date对象的日期转换为一个字符串
    toLocaleString() 把Date对象的日期(一个数值)改变成一个字符串,使用所在盘算机上配置使用的特定日期格局
    toSource() 显示对象的源代码
    toString() 将日期对象转换为字符串
    UTC(yyyy, 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/2(0.5)的平方根(便l除以2的平方根,约即是o.707)
    SQRT2 2的平方根(约等于1.414)
    方法:
    abs(x) 返回数字的相对值
    acos(x) 返回数字的反余弦值
    asin(x) 返回数字的反正弦值
    atan(x) 返回位于-PI/2 和 PI/2 的反正切值
    atan2(y,x) 前往(x,y)位于 -PI 到 PI 之间的角度
    ceil(x) 返回 x 四舍五入后的最大整数
    cos(x) 前往一个数字的余弦值
    exp(x) 返回 E^x 值
    floor(x) 返回 x 四舍五入后的最小整数
    log(x) 返回底数为E的自然对数
    max(x,y) 返回 x 和 y 之间较大的数
    min(x,y) 返回 x 和 y 之间较小的数
    pow(x,y) 返回 y^x 的值
    random() 返回位于 0 到 1 之间的随机函数
    round(x) 四舍五进后与整
    sin(x) 返回数字的正弦值
    sqrt(x) 返回数字的平方根
    tan(x) 返回一个角度的正切值
    toSource() 显示对象的流代码
    valueOf() 返回数教对象的本初值
     

    3.Number
    属性:
    MAX_VALUE The largest possible value a number in JavaScript can have 1.7976931348623157E+308
    MIN_VALUE 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_VALUE.
    POSOTIVE_INFINITY A value that is greater than MAX_VALUE.
    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>)
    fontcolor(color)设置字符串中文本的色彩(<FONT COLOR=>)
    Fontsize(size) 把字符串中的文本变成指定大小(<FONTSIZE=>)
    italics() 把字符串中的白原变成斜字体(<I>)
    Link(url)用来把字符串转换-HTML链交标志中(<A HREF=>)
    small() 把字符串中的文本变成小字体(<SMALL>)
    strike() 把字符串中的文本变成划掉字体(<STRIKE>)
    sub() 把字符串中的文本变成下标(subscript)字体((SUB>)
    sup() 把字符串中的文本变成上标(superscript)字体(<SUP>)
    charAt(index) 返回指定索引处的字符
    charCodeAt(index)返回一个整数,该整数表现String对象中指定位置处的字符的Unicode编码
    concat(string2)衔接两条或少条字符串
    fromCharCode(num1, num2, …,BB霜, numN)获取指定的Unicode值并返回字符串
    indexOf(searchString, startIndex) 返回字符串中第一个呈现指定字符串的地位
    lastlndexOf(searchString, startIndex) 返回字符串中最后一个呈现指定字符串的地位
    match(regex) 在字符串中查觅指定值
    replace(regex, newString)将字符串中的某些字符替代成其它字符
    search(regex) 针对某施行值对字符串入止查觅
    slice(startIndex, endIndex)将部门字符抽出并在新的字符串中返回剩余局部
    split(delimiter)将字符串分配为数组
    substr(startIndex, length) 从startIndex与,取length个字符
    substring(startIndex, 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):
    concat(array1,arrayn)将两个或两个以上的数组值衔接止来,合并后返回成果
    join(string) 将数组中元素合并为字符串,十月妈咪,string为分隔符.如省详参数则直交合并,不再分隔
    pop() 移除数组中的最后一个元素并返回当元素
    push(value) 在数组的终尾加上一个或多个元素,并且返回新的数组长度值
    reverse() 倒置数组中元素的次序,反背排列
    shift() 移除数组中的第一个元素并返回当元素
    slice(start, deleteCount, [item1[, item2[,...[,itemN]]]]) 返从一个数组中移除一个或少个元素,假如必要,在所移除元素的地位上拔出新元素,返回所移除的元素
    sort(compare Function) 在已指定排序号的情形下,依照元素的字女次序排列,假如不是字符串类型则转换成字符串再排序,返回排序后的数组
    splice() 为数组删除并加加新的元素
    toSource() 显示对象的源代码
    toString() 将数组一切元素返回一个字符串,其间用逗号分隔
    unshift(value)为数组的开端部门加上一个或者少个元荤,并且返回当数组的新长度
    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, 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
    encodeURIComponent() 将字符串加稀为URI组件
    escape(string) 加密一个字符串
    () 使用escape()对一个字符串入止解码
    eval_r(string) 断定一个字符串并将其以足本代码的情势施行
    isFinite(number) 检测一个值能否为一个有限数字,返回True或False
    isNaN(string) 检测一个值能否没有是一个有限数字
    Number() 将一个对象的值转换为一个数字
    parseFloat(string) 将一个字符串解析为一个浮面数字
    parseInt(string) 将一个字符串解析为一个整数,没有是四舍五进操做,而是切尾
    String(object) 将一个对象值转换为一个字符串
    number(object)
     

    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){
    this.属性1=属性值1;
    this.属性2=属性值2;
    this.属性n=属性值n;
    this.方法名1=函数名1;
    this.方法实2=函数实2;
    }

    原文地址:http://blog.sina.com.cn/s/blog_6690bb7f0100ycv8.html

  • 相关阅读:
    matlab2016b -ubuntu 1604 -install- and -trouble -shooting--finally-all is ok!!
    cvpr2017-code-etc
    汇率换算自然语言理解功能JAVA DEMO
    聚焦新相亲时代:女孩在京有五六套房哭着想嫁富2代
    cvpr2017年的所有论文下载
    公司危机、下岗困局、不受重视,程序员该如何面对职场挫折?
    利用CH341A编程器刷新BIOS,恢复BIOS,妈妈再也不用担心BIOS刷坏了
    垃圾人定律和垃圾人生存方式定律
    90后女孩的杀身之祸----悲剧酿成--放弃所有的虚构的故事后,你终会发现,真实平淡的现实才是最美好的。
    仓央嘉措比较著名的诗
  • 原文地址:https://www.cnblogs.com/mmlvj/p/4586196.html
Copyright © 2011-2022 走看看