OLOO创作的差异?

时间:2018-05-08 23:47:02

标签: javascript

除了第二个Foo没有原型链之外,这两个版本的Foo还有其他差异吗?

typeof说有两个对象和其他对象,我看不到行为等其他变化,除非我遗漏了某些东西......

<button id="prev-search-button" ng-click="prevAdd(subtract)"><</button> 
<button id="prev-search-button" ng-click="prevAdd(add)"><</button>  

$scope.prevAdd = function(arg){  
  var search = $scope.inputDate ? $scope.inputDate: moment() ;  
  $scope.day = moment(search).arg(1, 'days').format('DD'); 
  $scope.month=moment(search).arg(1, 'days').format('MM'); 
};

var Foo = {
    init: function(who) {
        this.me = who;
    },
    identify: function() {
        return "I am " + this.me;
    }
};

var Bar = Object.create( Foo );

Bar.speak = function() {
    alert( "Hello, " + this.identify() + "." );
};

var b1 = Object.create( Bar );
b1.init( "b1" );
var b2 = Object.create( Bar );
b2.init( "b2" );

b1.speak();
b2.speak();

0 个答案:

没有答案