0

that is a piece of code transpiled into javascript by typescript.

"

    var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var A = /** @class */ (function () {
    function A() {
    }
    return A;
}());
var B = /** @class */ (function (_super) {
    __extends(B, _super);
    function B() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return B;
}(A));

"

i am struggling to understand that and have attained a certain degree of success, still a few question remains:

first:

function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };. "b.hasOwnProperty"

b is already an instance right? because i tried to loop through properties of function/class and haven't got it made. can only loop through instance's properties unless i am doing something wrong.

second: are Object.setPrototypeOf and { __proto__: [] } for the purpose of check browser compatibility?

i'm still new to javascript as it is noticeable n the question, but very excited about it even when i get stucked into something which is the case.

thank you all!!!!

Fissure King
  • 1,250
  • 7
  • 17
henricoo
  • 17
  • 2
  • 1
    JavaScript uses prototype-based inheritance, not classical inheritance, so JavaScript doesn't distinguish between functions/classes and instances. You can copy properties between classes in the same way you can with any other object. – 4castle Jun 29 '18 at 13:06
  • For your second question, yes, it's for browser compatibility. – 4castle Jun 29 '18 at 13:08

0 Answers0