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

160
Views
Non Predefined Javascript Function Names and their execution

I'm not sure this kind of feature is available in Javascript. Here is what I wanted to archive.

Let's say we have an object instance called obj and I want to call any function in this object instance but I'm not defining the function name at the beginning.

const obj = {};

obj.functionOne({id: 1}); // execution 1
obj.functionTwo({id: 1}); // execution 2

I wanted to execute one single function (_default) for both execution 1 and execution 2. withing that function I need to know what is the function name actually executed.

eg:


obj = {

  _default: (params) {
    console.log('Function Name is', Function.name); // will be print `functionOne` or `functionTwo`
    console.log(params); // will be print {id: 1} for both cases.
  }

}

Can someone give me some insight on how to archive this kind of requirement?

Thanks in advance.

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!