const finder = new FinderClass();
const gallery1 = new GalleryClass(finder);
const gallery2 = new GalleryClass(finder);
在finder
:finder.search(query)
上有一个“搜索”方法。当我打电话给“搜索”时,如何知道呼叫者是gallery1
还是gallery2
?
var GalleryClass = function(finder) {
this._finder = finder;
}
GalleryClass.prototype = {
doSearch(query) {
return this._finder.search(query);
}
}