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

272
Views
Receiver in Reflect.get() not working as expected

I wrote a proxy of HTMLAudioElement. When I call play() method via the proxy.

const proxy = new Proxy( audioPlayer, {
  get(target: typeof audioPlayer , prop, receiver) { 
    return Reflect.get(target, prop, receiver);
  }
});
proxy.play();

I got a Error:

TypeError: Failed to execute 'play' on 'HTMLMediaElement': Illegal invocation

As far as I know, it is because that the play function is not bind to target. However, Shouldn't the prop receiver do the binding for us? Or something wrong in my code?

Then, I have to change my code as below, it looks weired, but works.

   const proxy = new Proxy( audioPlayer, {
        get(target: typeof audioPlayer , prop, receiver) { 
            if(prop=='play'){
                return target.play.bind(target)
            }else if(prop=='pause'){
                return target.pause.bind(target)
            }
            return Reflect.get(target, prop, receiver);
        }
   });
   proxy.play();
about 4 years ago · Juan Pablo Isaza
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!