tistory view
reverse() 메소드 -
배열의 순서를 반전함.
첫번째 요소는 마지막 요소가 되며 마지막 요소는 첫번째 요소가 됨.
const array1 = ['one', 'two', 'three'];
console.log('array1;', array1);
//expected output: "array1:" Array ["one", "two", "three"]
const reversed = array1.reverse();
console.log('reversed:', reversed);
//expected output: "reversed:" Array ["three", "two", "one"]
//Careful: reverse is destructive -- it changes the original array.
console.log('array1:', array1);
//expected output: "array1:" Array ["three", "two", "one"]
'Javascript' 카테고리의 다른 글
pop() 메소드 (0) | 2022.02.07 |
---|---|
splice() 메소드 (0) | 2022.02.07 |
unshift() 메소드 (0) | 2022.02.07 |
shift() 메소드 (0) | 2022.02.07 |
sort() 메소드 (0) | 2022.02.07 |
comment
© 2022 Jane Doe