js实现栈
来源:互联网 发布:松下fpwin编程手册 编辑:程序博客网 时间:2024/06/05 20:16
<script type="text/javascript">function Stack() {this. dataStore = [] ;this. top = 0;this. push = push;this. pop = pop;this. peek = peek;this. clear = clear;this. length = length;}function push(element) {this. dataStore[this. top++] = element;}function peek() {return this. dataStore[this. top- 1] ;}function pop() {return this. dataStore[- - this. top] ;}function clear() {this. top = 0;}function length() {return this. top;}function doTest(){var s = new Stack();s. push(" David" );s. push(" Raymond" );s. push(" Bryan" );document.write(" length: " + s. length());document.write(s. peek());var popped = s. pop();document.write(" The popped element is: " + popped);document.write(s. peek());s. push(" Cynthia" );document.write(s. peek());s. clear();document.write(" length: " + s. length());document.write(s. peek());s. push(" Clayton" );document.write(s. peek());}</script>
0 0
- js实现栈
- js实现栈
- js实现栈结构
- js实现栈类
- JS实现栈结构
- 栈的JS实现
- 用js实现一个栈
- 数据结构:用JS实现栈
- 【Js】js实现ajax
- Js实现
- js数组实现队列和栈
- js数组实现队列和栈
- 用js来实现栈的对象
- 【JS】:JS实现网页计算器
- JS 时钟的js实现
- js分页实现,前端实现。
- 用JS实现缩略图
- js中实现重载
- js实现列表类
- js中数组迭代函数—(1)不生成新数组
- ERROR: ORACLE initialization or shutdown in progress 解决方案
- js中数组迭代函数—(2)会生成新数组
- 【转自mos文章】数据库 hang问题的诊断信息收集方法
- js实现栈
- 00初识python3
- 不要把 Python 写成 C 语言版的 Python
- USACO 1.1 Broken Necklace
- 基于阿里云Ubuntu14.04 64bit部署WordPress博客系统
- How To Create A Struts 2 Web Application
- 新建Android工程报错:'Building workspace' has encountered a problem...解决办法
- Leetcode #141 Linked List Cycle Python
- iOS部分-UI基础控件 - 01天 入门 第11课 上下左右移动