当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 个人总结的一些关于String、Function、Array的属性和用法

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

Javascript 中的 个人总结的一些关于String、Function、Array的属性和用法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-12   浏览: 158 ::
收藏到网摘: n/a

复制代码 代码如下:

/* Array */
Array.reverse() //数组反向排序,变成新数组。
Array.sort() //把数组按字符排序,变成新数组。
s=Array.push("str1","str2") //从后面添加数组,s为添加记录
s=Array.pop() //从后面删除数组,s为被删记录
s=Array.shift() //从前面删除数组,s为被删记录
s=Array.unshift("str1","str2") //从前面添加数组,s为添加记录
s=Array.splice(3,2,"aa","bb") //从数组的第三个后面开始,向后删除两个数组,并在该位置添加新的数组。s为添加记录
s=Array.slice(2,4) //从数组的第二个后面开始取值,取到第四个,数组本身未改变。
s=Ar1.concat(Ar2) //把数组Ar2添加到数组Ar1内,产生新数组s。
s=Array.join("#") //把数组元素用#连接,形成字符串并返回给s。
/* Function */
Sample:function Test(arg1,arg2)
Use:Test("ddd", "sss", "fff")
//Test.arity: //函数设定的参数个数(返回数值)。
Test.length: //函数设定的参数个数(返回数值)。
Test.caller: //调用Test()的函数(返回函数,IE支持)。
Test.apply(obj, [arg1, arg2]) //使得指定对象(obj)具有Test的属性和方法。
Test.call(obj, arg1, arg2) //使得指定对象(obj)具有Test的属性和方法。
arguments: //实际传入的参数个数(返回数组)。
arguments.callee: //当前执行的函数(返回函数)。
(new Test).constructor: //查看新实例(Test())的构造(返回函数)。
/* String */
Str.slice(3,-5) //从第三个字符串后面开始取值,取到第-5个(倒数第五个。参数二需大于参数一,或为负)。
Str.substring(3,6) //从第三个字符串后面开始取值,取到第6个。
Str.substr(3,6) //从第三个字符串后面开始取值,向后取6个字符。
Str.charCodeAt(4) //返回第5个字符串的10进制编码。
Str.charAt(4) //返回第5个字符串。
Str.toLowerCase() //全部转化成小写字符。
Str.toUpperCase() //全部转换成大写字符。
Str.split(",") //使用“,”分割字符串,并返回数组。
Str.search("aaa") //查找aaa在字符串中的位置,一般和正则表达式一起使用。
Str.indexOf("aaa") //查找aaa在字符串中的位置。
Str.lastIndexOf("aaa") //从后面开始查找"aaa"在字符串中出现的位置。
Str.match("aaa") //从Str中取出"aaa",返回null或数组,一般和正则表达式一起使用。
Str.replace("aaa","bbb") //把第一个“aaa”替换成“bbb”,一般和正则表达式一起使用。
String.fromCharCode(39080) //返回一个10进制编码生成的字符。
str1=str2.concat(str3) //将str3添加到str2生成新的字符串str1。