摘要: indexOf() 从数组开头查找 语法: arrayObject.indexOf(searchvalue,startIndex) 功能: 从数组的开头(位置0)开始向后查找。 参数: searchvalue:必需,要查找的项 startIndex:可选,起点位置的索引 返回值: number,查找 阅读全文
posted @ 2018-09-18 23:44 键1234 阅读(1260) 评论(0) 推荐(0) 编辑
摘要: var str = "hello world"; document.write(str[1]); //输出结果e ie7前的浏览器不兼容 document.write(str.charAt(0)); //输出结果h 兼容浏览器 document.write(str.charCodeAt(4)); / 阅读全文
posted @ 2018-09-18 23:43 键1234 阅读(986) 评论(0) 推荐(0) 编辑
摘要: var p1 = new Array(1,2,3); console.log(p1); var p2 = ["red","yellow","green"] console.log(p2); var p3=[1,"name",true]; console.log(p3); console.log(p3 阅读全文
posted @ 2018-09-18 23:43 键1234 阅读(101) 评论(0) 推荐(0) 编辑
摘要: //push 在数组后面加值 var colors=new Array("red","blue"); var len = colors.push("green","yellow","black"); console.log(len); //输出结果为5 console.log(colors); // 阅读全文
posted @ 2018-09-18 23:43 键1234 阅读(188) 评论(0) 推荐(0) 编辑
摘要: join方法 把数值转换为字符串,可以改变连接符号 var nums= [2,3,4,5,9]; var str = nums.join(); console.log(str); //输出结果 2,3,4,5,9 var num= ["a","b","c","d"]; var str1 = num. 阅读全文
posted @ 2018-09-18 23:43 键1234 阅读(144) 评论(0) 推荐(0) 编辑
摘要: concat() 连接2个或者多个数组 var v1 = ["1","2","3"],v2 = ["4","5","6",9,8],v3; v3 = v1.concat(v2,["m",99,8]); slice(); var color=["red","blue","green","yellow" 阅读全文
posted @ 2018-09-18 23:43 键1234 阅读(106) 评论(0) 推荐(0) 编辑
摘要: splice()方法 删除 arrayObject.splice(index,count) 功能: index处开始的零个或者多个元素, 返回值: 含有被三处的元素的数组 说明: count 是要删除的项目数量。如果设置为0 ,则不会删除羡慕。如果不设置,则删除从index开始的所有值 例子: va 阅读全文
posted @ 2018-09-18 23:43 键1234 阅读(1189) 评论(0) 推荐(0) 编辑