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

161
Views
Execute top-level JavaScript function inside an arrow function

Let's say I'm using Vue 3 and Websockets (for context) and I have this wrapped inside a <script setup> tag.

function hello() {
  console.log("world")
}

const mapper = () => {
  // self.hello is not a function 
  self['hello']();
}

mapper();

How do I execute a function using only strings because I plan on adding more and need mapper to map them to functions outside of onmessage.

I am using TypeScript 4.4 and get:

Uncaught TypeError: self.hello is not a function
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!