
[자료구조][JS] 스택, 큐 - push(), pop(), shift()
·
Algorithm/Data Structure, Algorithm
기본적인 자료구조인 스택, 큐에 대해서 JS로 정리해보려 한다. push() push() 메서드는 배열의 끝에 하나 이상의 요소를 추가하고, 배열의 새로운 길이를 반환한다. arr.push(element1[, ...[, elementN]]) elementN: 배열의 끝에 추가할 요소. const animals = ['pigs', 'goats', 'sheep']; const count=animals.push('cows'); console.log(count); // expected output: 4 console.log(animals); // expected output: Array ["pigs", "goats", "sheep", "cows"] animals.push('cats', 'dogs'); conso..