Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7995007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:16:55+00:00 2026-06-04T14:16:55+00:00

After reading many times this question and its accepted answer How to execute a

  • 0

After reading many times this question and its accepted answer How to execute a JavaScript function when I have its name as a string

I tried to do it on my own. but I think its my unlucky day today that what I had tried was not working. I created already a fiddle for my testing

//the function I want to invoke by String
function CheckMe() {
    return "haha";
}

//the function that will search for the function and invoke it
function InvokeChecking(func2check) {
    var fn = func2check;
    if (typeof fn === 'function') {
        return = fn(); //invoke the function
    }
}

//the event listener  ( ´ ▽ ` )ノ
$("#checker").click(function () {
    alert("event is working");
    alert(InvokeChecking("CheckMe"));
});​

http://jsfiddle.net/laupkram/qKHpu/2/

the thing I want to do is to invoke the function I declared by using string and get its return value. So I followed what I saw here in SO using the (fn==='function') argument. but it seems not working for me.

where I went wrong?

NOTE: I already check it in firebug and my function exist… Did I fall in a scoping problem? or something?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:16:56+00:00Added an answer on June 4, 2026 at 2:16 pm

    http://jsfiddle.net/qKHpu/8/

    You need to pass in the literal name of the function, without quotes ("), otherwise it’ll be treated as a literal string, which is meaningless

    alert(InvokeChecking(CheckMe)); // instead of alert(InvokeChecking("CheckMe"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Yes I know, this question has been asked MANY times but after reading all
After reading a description about swapping pointer addresses on Stackoverflow, I have a question
After reading this question , I've learned that denormalization is not a solution for
After posting this question and reading that one I realized that it is very
I have done this successfully many times before, but this time it just won't
This question comes up after reading a comment in this question: Database Design When
I think this has been done many times before but despite reading some posts
After reading a bit on Javascript's prototypical inheritance model , I change my style
After reading this post I kinda felt in the same position as the guy
After reading this article on thedailywtf.com, I'm not sure that I really got the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.