摘要:
function Stack() { this.dataStore = []; this.top = 0;//top的值等同于数组内的元素个数 this.push = push; this.pop = pop; } function push(element) { this.dataSt... 阅读全文
摘要:
栈被称为一种后进先出( LIFO, last-in-first-out) 的数据结构。 tips:pop()&peek()的区别: pop() 方法可以访问栈顶的元素, 调用后, 栈顶元素从栈中被永久性地删除。 peek() 方法则只返回栈顶元素, 而不删除它。 阅读全文
摘要:
function List() { this.listSize = 0;//列表的元素个数,属性 this.pos = 0;//列表的当前位置,属性 this.dataStore = []; // 初始化一个空数组来保存列表元素 this.length = length;//返回列表中元素的个数 this.... 阅读全文
摘要:
function List() { this.listSize = 0;//列表的元素个数,属性 this.pos = 0;//列表的当前位置,属性 this.dataStore = []; // 初始化一个空数组来保存列表元素 this.append = append;//在列表的末尾添加新元素,方法 ... 阅读全文
摘要:
function weekTemps() { this.dataStore = [];//属性 this.add = add;//方法 this.average = average;//方法 } function add(temp) { this.dataStore.push(temp); } ... 阅读全文
摘要:
function Point(x, y) { this.x = x; this.y = y; } function displayPts(arr) { for ( var i = 0; i "); } } var p1 = new Point(1, 2); var p2 = new P... 阅读全文
摘要:
var grades = [ [ 89, 77 ], [ 76, 82, 81 ], [ 91, 94, 89, 99 ] ]; var total = 0; var average = 0.0; for ( var row = 0; row "); total = 0; average = 0.0; } 阅读全文