Last active
December 24, 2015 18:12
-
-
Save LincolnBurrows/7227334603f15ea3760d to your computer and use it in GitHub Desktop.
js数组对象操作
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = new Array(); | |
arr[0] = {"name":"LincolnBurrows","age":"26","sex":"male"}; | |
arr[1] = {"name":"yangdong","age":"20","sex":"male"}; | |
arr[2] = {"name":"jingjing","age":"19","sex":"female"}; | |
arr.push({"name":"kkkk","age":"2222"}); //数组push方法,相反pop方法 | |
arr.pop({"name":"kkkk","age":"2222"}); | |
for(var i = 0;i < arr.length;i++) | |
{ | |
console.log(arr[i]); //打印每一项 | |
var user1 = {name:"jingjing"}; | |
if (arr[i].name == user1.name) //或者直接等于"jingjing"字符串 | |
console.log(arr[i]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment