배열의 요소에 순차적으로 접근하여 필요한 값을 생성할 수 있다. 배열의 메서드이므로 다른 객체에서 사용할 수 없다.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
let fruits = ["Banana","Orange","Apple","Mango"];
fruits.forEach(function(value,index,array) {
console.log(value);
console.log(index);
console.log(array);
});
</script>
</body>
</html>
'웹 프로그래밍 기초 > 객체' 카테고리의 다른 글
indexOf(), search() (0) | 2025.04.09 |
---|---|
내장 객체(String) (0) | 2025.04.08 |
delete 연산자 (0) | 2025.04.07 |
sort(), reverse() (0) | 2025.04.07 |
splice(), slice() (0) | 2025.04.07 |