Use two stacks , one for enqueuing, another one for dequeuing.
function enqueue(){
if (stack1.length !== 0){
while (stack2.length !== 0){
stack1.push(stack2.pop());
}
}
return stack1.pop();
}
function dequeue(){
if (stack2.length !== 0){
while(stack1.length !== 0){
stack2.push(stack1.pop());
}
}
return stack2.pop();
}