Answer the question
In order to leave comments, you need to log in
How to add a mixin with a large nesting to the class so that the this class would be inside the functions?
let users = {foo: {bar: {function baz() {
this.req()
}}}}
let test = {function test() {
this.req()
}}
class API{
req() {
console.log('req')
}
}
Object.assign(API.prototype, {users})
new API().users.foo.bar.baz()//this undefined
Object.assign(API.prototype, test)
new API().test()//req
Answer the question
In order to leave comments, you need to log in
https://developer.mozilla.org/en/docs/Web/JavaScri...
https://developer.mozilla.org/en/docs/Web/JavaScri...
https://developer.mozilla.org/ en/docs/Web/JavaScri...
https://developer.mozilla.org/en/docs/Web/JavaScri...
https://developer.mozilla.org/en/docs/Web/JavaScri...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question