JS/JS 수업분

[JS] day10_array_Method_배열순환탐색 메서드

congs 2023. 4. 18. 22:17
 
 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>배열 순환 탐색 메서드</title>
</head>
<body>
    <h1>배열의 순환할 수 있는 구조를 이용하여 특정 기능을 할 수 있는 메서드 제공</h1>

    <script>
        const fruits = ['apple', 'Orange', 'apple', 'banana'];

        // 뒤쪽 apple에 있는 'l' 찾기
        let key = fruits[fruits.indexOf('apple',1)]; //1번지부터 검색해 나온 apple
        console.log(key);
        // let key1 = fruits[fruits.indexOf('apple',1)].indexOf('l'); //1번지부터 검색해 나온 apple의 l의 위치: 3
        let key1 = fruits[fruits.indexOf('apple',1)].indexOf('app')+'app'.length;
        console.log(key1);

        const f = fruits.entries();
        console.log(f); // 보지 못함
        for(const g of f){
            console.log(g);
            console.log(typeof g);
        };
    </script>
</body>
</html>
 
 

'JS > JS 수업분' 카테고리의 다른 글

[JS] day10_updown과제  (0) 2023.04.18
[JS] day10_regular_expression_정규표현식 (파일명검색)  (0) 2023.04.18
[JS] day10_array_interation  (0) 2023.04.18
[JS] day10_Json  (0) 2023.04.18
[JS] day10_array_Sort  (0) 2023.04.18