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

123
Views
Dynamically create functions and import them by name

I'm trying to create a file which generates dynamically named functions based on the import names being imported by another file.

So is it possible to do something like this:

// File index.js
import { function1, function2 } from 'functionGen.js'

function1('hello, world!') // Console prints 'hello, world!'
function2('test') // Console prints 'test'
// File functionGen.js

export default (name) => return new Function('return function ' + name + '(msg){console.log(msg)}') 
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!