记录
huangpeng777
这个作者很懒,什么都没留下…
展开
-
js实现二叉搜索树
class Node { constructor(key) { this.key = key; this.left = null; this.right = null; } } class BinarySearchTree { constructor() { this.root = null; } insert(key) { const newNode = new Node(key); if (this.root === null)原创 2020-12-02 16:37:25 · 91 阅读 · 0 评论 -
js实现单向链表
class Node { constructor(data) { this.data = data; this.next = null; } } class LinkedList { constructor() { this.length = 0; this.head = null; } append(data) { const newNode = new Node(data); if (this.length === 0) {原创 2020-12-02 16:19:31 · 142 阅读 · 0 评论 -
js实现栈结构
class Stack { //属性 constructor() { this.items = []; } //压栈 push(ele) { this.items.push(ele); } //弹栈 pop() { return this.items.pop(); } //peek peek() { return this.items[this.items.length - 1]; } //判断是否为空 isEmpty.原创 2020-12-02 16:09:10 · 78 阅读 · 0 评论 -
js实现继承的几种方式
1.原型链继承 function Father(name) { this.name = name || 'father'; } Father.prototype.printName = function () { console.log(this.name); }; function Son() {} Son.prototype = new Father();原创 2020-11-12 11:20:49 · 175 阅读 · 1 评论 -
Vuex 区分 State 是外部直接修改,还是通过commit修改
computed: { height() { return this.KaTeX parse error: Expected 'EOF', got '}' at position 29: …eight; }̲, flag(…store.state; } }, watch: { flag: { handler() { if (this.KaTeX parse error: Expected '}', got 'EOF' at end of input: …nsole.log(t原创 2020-11-11 17:07:37 · 723 阅读 · 0 评论