map.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src="http://code.jquery.com/jquery-3.2.1.min.js"></script>
<script>
var arrName=["갑","을","병", "정"];//배열
//배열.map(function(값, 변수명){})
//배열을 map으로 변환
$(function(){
var arr=arrName.map(function(value, key){
console.log("value:"+value +",key :"+ key);
});
console.log(arr);
});
</script>
</head>
<body>
</body>
</html>
value:갑,key :0
map.html:14 value:을,key :1
map.html:14 value:병,key :2
map.html:14 value:정,key :3
map.html:17 Array(4)0: undefined1: undefined2: undefined3: undefinedlength: 4__proto__: Array(0)
댓글 ( 4)
댓글 남기기