Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

121
Views
js log binded object

I have a function binded to an object, how can I access to the object at the same scope with the function?

let f = function(){};
class A{}
f = f.bind(new A());
// console.log(f.bindedObject)

what about in a method?

class B{
    constructor(func){
        this.func = func;
    }

    log(){
        // console.log(this.func.bindedObject)
    }
}

class A{}
let b = new B(function(){}.bind(new A()));
b.log()
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You could overwrite the bind method

(function() {
    let bind = Function.prototype.bind;
    Function.prototype.bind = function(newThis) {
        let bf = bind.apply(this, arguments);
        bf.newThis = newThis;
        return bf;
    };
})();

var f = function() {};
var nf = f.bind({'hello':1});
console.log('newThis', nf.newThis);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!