スタック{クラス コンストラクタ(){ この .LIST = []; } // スタック プッシュ(項目){ この.list.push(項目); } // アウトバウンド ポップ(){ 戻り 、この(.list.pop)を; } //は、スタックが空であるか否かを判断 GetIsEmpty(){ 戻り 、この .list.length == 0 ; } // スタックサイズ のgetSize(){ 戻り 、この.list.lengthを; } //清空栈 クリア(){ この .LIST = []; } // 读出栈数据 読む(){ にconsole.log(この.list.toString())。 } } // 使用 stackInfo =ましょう新しい)(スタック。 stackInfo.GetIsEmpty(); // 真 stackInfo.Push(11 )。 stackInfo.Push( 10 )。 stackInfo.Read(); // 11,10 stackInfo.GetSize(); // 2 stackInfo.Pop()。//10 stackInfo.Read()。// 11