My question is on the following expression:
var prototype = Object.create(extend && extend.prototype);
I think it's creating the prototype object inheriting the extend object. And extend && extend.prototype
is checking to see if extend exists and extend.prototype exists. If either one doesn't exist, prototype will be a object without superclass. And if both exist, prototype will inherit extend? How does it know to use extend.prototype
with extend && extend.prototype
syntax?
So var prototype = Object.create(extend && extend.prototype)
and var prototype = Object.create(extend.prototype)
are the same if both extend
and extend.prototype
are there?
Thanks.