摘要: function Stack() { this.dataStore = []; this.top = 0;//top的值等同于数组内的元素个数 this.push = push; this.pop = pop; } function push(element) { this.dataSt... 阅读全文
posted @ 2016-04-09 21:25 绯乐 阅读(732) 评论(0) 推荐(0) 编辑
摘要: 栈被称为一种后进先出( LIFO, last-in-first-out) 的数据结构。 tips:pop()&peek()的区别: pop() 方法可以访问栈顶的元素, 调用后, 栈顶元素从栈中被永久性地删除。 peek() 方法则只返回栈顶元素, 而不删除它。 阅读全文
posted @ 2016-04-09 20:15 绯乐 阅读(11383) 评论(0) 推荐(0) 编辑
摘要: function List() { this.listSize = 0;//列表的元素个数,属性 this.pos = 0;//列表的当前位置,属性 this.dataStore = []; // 初始化一个空数组来保存列表元素 this.length = length;//返回列表中元素的个数 this.... 阅读全文
posted @ 2016-04-09 11:24 绯乐 阅读(288) 评论(0) 推荐(0) 编辑
摘要: function List() { this.listSize = 0;//列表的元素个数,属性 this.pos = 0;//列表的当前位置,属性 this.dataStore = []; // 初始化一个空数组来保存列表元素 this.append = append;//在列表的末尾添加新元素,方法 ... 阅读全文
posted @ 2016-04-09 11:15 绯乐 阅读(165) 评论(0) 推荐(0) 编辑
摘要: function weekTemps() { this.dataStore = [];//属性 this.add = add;//方法 this.average = average;//方法 } function add(temp) { this.dataStore.push(temp); } ... 阅读全文
posted @ 2016-04-09 10:18 绯乐 阅读(486) 评论(0) 推荐(0) 编辑
摘要: 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... 阅读全文
posted @ 2016-04-09 10:14 绯乐 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 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; } 阅读全文
posted @ 2016-04-09 10:04 绯乐 阅读(321) 评论(0) 推荐(1) 编辑
摘要: 一、按列访问:外层循环对应行, 内层循环对应列。 二、按行访问:外层循环对应列, 内层循环对应行。 阅读全文
posted @ 2016-04-08 22:11 绯乐 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 一、对于小规模数据 二、对于大规模数据 阅读全文
posted @ 2016-04-08 21:49 绯乐 阅读(300) 评论(0) 推荐(0) 编辑
摘要: 一、map():对数组中的每个元素使用某个函数,并返回一个新的数组, 该数组的元素是对原有元素应用某个函数得到的结果。 二、filter():传入一个返回值为布尔类型的函数,当对数组中的所有元素应用该函数, 结果均为 true 时, 该方法并不返回 true, 而是返回一个新数组, 该数组包含应用该 阅读全文
posted @ 2016-04-08 21:34 绯乐 阅读(422) 评论(0) 推荐(0) 编辑