jquery方法

1.shift():该方法用于将数组中的第一个元素删掉,如:
var colors = [“red”, “white”, “blue”, “green”];
var delell = colors .shift();
删除后数组为: [“white”, “blue”, “green”];
删除的元素是: red;

2.pop():该方法用于将数组最后一个元素移除

3.unshift():该方法用于在数组前端添加元素

4.push():该方法用于在数组末端添加元素

5.charAt(index):该方法可返回指定位置的字符,括号里面的参数为必需,表示字符串中某个位置的数字。示例如下:

var str="Hello world!" document.write(str.charAt(1))

以上代码的输出是:e
同时, charAt() 方法也可用于JAVA后台,意义同jquery里是一样的,均可用于返回指定索引处的字符。索引范围为从 0 到 length() - 1。示例如下:
public class Test {

public static void main(String args[]) {
    String s = "hello world";
    char result = s.charAt(1);
    System.out.println(result);
}

}
以上程序执行结果为:e

猜你喜欢

转载自blog.csdn.net/shenxiaomo1688/article/details/81353060