728x90 자바#자바스크립트#JS#javascript1 [Learn.JS] JavaScript-2 (Array 다루기, 연산자, 조건문) Manipulating Arrays Pushing and popping Array들은 스택의 역할도 한다. push와 pop 메서드는 array의 끝에 데이터를 insert 하거나 제거해준다. 예를 들어, 빈 array를 만들고 몇 개의 변수들을 push 해주겠다. var myStack = []; myStack.push(1); myStack.push(2); myStack.push(3); console.log(myStack); 이렇게 출력 될 것이다. 1,2,3 array에 변수들을 push 한 후에 끝에 있는 변수들을 pop 할 수 있다. console.log(myStack.pop()); console.log(myStack); 그러면 배열에서 꺼낸 변수와 배열의 남은 부분이 출력됩니다. 3 // the .. 2022. 1. 7. 이전 1 다음 728x90