1. class Stack{
    2. constructor(){
    3. this.items=[];
    4. }
    5. push(value){
    6. this.items.push(value)
    7. }
    8. pop(){
    9. return this.items.pop()
    10. }
    11. peek(){
    12. return this.items[this.items.length-1]
    13. }
    14. isEmpty(){
    15. return this.items.length==0;
    16. }
    17. size(){
    18. return this.items.length;
    19. }
    20. }
    21. var s=new Stack();
    22. s.push(2);
    23. s.push(3);
    24. console.log(s.size())