tistory view
sort() 메소드 -
배열의 요소를 적절한 위치에 정렬한 후 그 배열을 반환.
const months = ['March', 'Jan', 'Feb', 'Dec'];
months.sort();
console.log(months);
//expected output: Array ["Dec", "Feb", "Jan", "March"]
const array1 = [1, 30, 4, 21, 100000];
array1.sort();
console.log(array1);
//expected output: Array [1, 100000, 21, 30, 4]
'Javascript' 카테고리의 다른 글
unshift() 메소드 (0) | 2022.02.07 |
---|---|
shift() 메소드 (0) | 2022.02.07 |
push() 메소드 (0) | 2022.02.07 |
상수 _ const (0) | 2022.02.02 |
변수 _ var (0) | 2022.02.02 |
comment
© 2022 Jane Doe