Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

mixin in js

function mixin<T extends { new (...args: any[]): {} }>(base: T, obj) {
  return class extends base {
    constructor(...args: any[]) {
      super(...args);
      Object.assign(this, obj);
    }
  };
}

export default mixin;
 
PREVIOUS NEXT
Tagged: #mixin #js
ADD COMMENT
Topic
Name
8+9 =