会员
周边
新闻
博问
闪存
众包
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
studystudyxinxin
博客园
首页
新随笔
联系
订阅
管理
2021年4月19日
剑指Offer 51 - 数组中的逆序对
摘要: 力扣链接:https://leetcode-cn.com/problems/shu-zu-zhong-de-ni-xu-dui-lcof/ 题目描述 在数组中的两个数字,如果前面一个数字大于后面的数字,则这两个数字组成一个逆序对。输入一个数组,求出这个数组中的逆序对的总数。 eg. 输入: [7,
阅读全文
posted @ 2021-04-19 00:50 studystudyxinxin
阅读(56)
评论(0)
推荐(0)
2020年10月27日
JS基础 - Class 原型 原型链
摘要: 1. class的基本使用 class Student { constructor(name, number){ this.name = name; this.number = number; } sayHi(){ console.log( `姓名 ${this.name} , 学号 ${this.
阅读全文
posted @ 2020-10-27 07:09 studystudyxinxin
阅读(361)
评论(0)
推荐(0)
2020年7月19日
剑指Offer 62 - 圆圈中最后剩下的数字
摘要: 力扣链接:https://leetcode-cn.com/problems/yuan-quan-zhong-zui-hou-sheng-xia-de-shu-zi-lcof/ 题目描述 0,1,,n-1这n个数字排成一个圆圈,从数字0开始,每次从这个圆圈里删除第m个数字。求出这个圆圈里剩下的最后一个
阅读全文
posted @ 2020-07-19 23:34 studystudyxinxin
阅读(144)
评论(0)
推荐(0)
2020年7月17日
剑指 Offer 59II - 队列的最大值
摘要: 力扣链接:https://leetcode-cn.com/problems/dui-lie-de-zui-da-zhi-lcof/ 题目描述 请定义一个队列并实现函数 max_value 得到队列里的最大值,要求函数max_value、push_back 和 pop_front 的均摊时间复杂度都是
阅读全文
posted @ 2020-07-17 23:02 studystudyxinxin
阅读(144)
评论(0)
推荐(0)
2020年7月15日
不使用class的六种继承实现方式总结
摘要: 原型链 假借构造函数 组合继承 原型式(Prototypal) 寄生式 组合寄生式 主要形式 subType.prototype = new SuperType() SuperType.call(this) subType.prototype = new SuperType() + SuperTyp
阅读全文
posted @ 2020-07-15 11:13 studystudyxinxin
阅读(228)
评论(0)
推荐(0)
继承的实现方式之 寄生组合式继承(Parasitic Combination Inheritance)
摘要: 普通的组合继承模式中,我们两次调用了父类的构造函数,导致父类的实例属性在子类实例和子类原型上同时存在。主要问题在于在第一次调用时,我们将一个父类实例作为子类的原型,使得父类的实例属性不必要的被复制到了子类原型上。 理想的效果是,只将子类原型的[[Prototype]]隐式属性指向父类原型,不在原型上
阅读全文
posted @ 2020-07-15 08:30 studystudyxinxin
阅读(149)
评论(0)
推荐(0)
继承的实现方式之 寄生式
摘要: 基本模式 原型式继承(Prototypal Inheritance)和工厂模式的结合,用一个函数先创建以父类为原型的对象,再为这个对象添加需要的子类属性及方法。最后直接返回这个对象。 function object(o){ function F(){} F.prototype = o; return
阅读全文
posted @ 2020-07-15 08:03 studystudyxinxin
阅读(112)
评论(0)
推荐(0)
继承的实现方式之 原型式继承(Prototypal Inheritance)
摘要: 基本形式 //创建一个以o为原型的对象 function object(o){ function F(){} F.prototype = o; return new F(); } let person = { name: "Jack", friends: ["Ann", "Bob"] }; let
阅读全文
posted @ 2020-07-15 07:41 studystudyxinxin
阅读(106)
评论(0)
推荐(0)
继承的实现方式之 组合继承
摘要: 基本形式 通过原型链继承原型属性及方法,通过假借构造函数继承实例属性及方法。 function SuperType(name){ this.name = name; this.colors = ["red", "blue"]; } SuperType.prototype.sayName = func
阅读全文
posted @ 2020-07-15 07:02 studystudyxinxin
阅读(170)
评论(0)
推荐(0)
继承的实现方式之 假借构造函数
摘要: 基本形式 function Person(name){ this.name = name; } Person.prototype.sayHi = function(){ console.log(this.name); } function Student(name, mark){ Person.ca
阅读全文
posted @ 2020-07-15 06:36 studystudyxinxin
阅读(97)
评论(0)
推荐(0)
下一页
公告