Spring data jpa 时间注解
先定义一个构造函数:
function Person(name,age){this.name = name;this.age = age;this.say = function(){console.log("hello world")}}Person.prototype.gender = male;
1.原型链继承:将子类的构造函数的原型变为父类的实例对象
Student.prototype = new Person();Student.prototype.constructor = Student
优点:实现简单
缺点:无法向父构造函数传参
2.通过构造函数继承
function Student(name,age){Person.call(this,name,age)this.name = name;this.age = age;this.say = function(){console.log("hello world")}}
缺点:无法访问父构造函数的原型中的方法
3.将子构造函数的原型修改为父构造函数的原型
function Student(name,age){Person.call(this,name,age)this.name = name;this.age = age;this.say = function(){console.log("hello world")}}Student.prototype = Person.prototypeStudent.prototype.constructor = Student
缺点:破坏了原型链,给子类的原型添加属性父类原型也会添加
4.将子类的原型设置为父类的实例对象
function Student(name,age){Person.call(this,name,age)this.name = name;this.age = age;this.say = function(){console.log("hello world")}}Student.prototype = new Person();
缺点:调用了两次父类构造函数,消耗内存

评论
