본문 바로가기
JS/Javascript

Array 정렬 2가지 sort, reverse (JAVASCRIPT)

by 싸공 2020. 7. 27.
<!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 arr = ['chicken''pigeon''swan''penguin''donkey''rabbit']
        console.log(arr.sort()); // 알파벳 순으로 정렬
        console.log(arr.reverse()); // 역순으로 정렬
        
    </script>
</body>
</html>