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

  • Home
  • SEARCH
  • 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 8743523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:41:37+00:00 2026-06-13T11:41:37+00:00

I have web application which use the jsonp which return javascript codes to the

  • 0

I have web application which use the jsonp which return javascript codes to the client.

This is the code I return (to make it unreadable):

com.xx.load('xx','var name="hguser";function data(x){console.info(x); }')

in the load function,we eval the codes.

However,we found that it is unreadable,but it is un-debuggeable.

So I wonder if we can use this:

com.xx.load('xx',function(){
  var name='hguser';
  function data(x){
    console.info(x); 
  }
});

Then,in the load function insead of eval the code string,we will now eval a function object.

Is this possible?

Does they mean the same thing?

  • 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-13T11:41:38+00:00Added an answer on June 13, 2026 at 11:41 am

    You sure can. It’ll be like simulating dynamic scoping in JavaScript. A few things to be aware of:

    1. You can’t just directly eval a function. You need to convert it to a string. Use eval(String(f)).
    2. Give the function f a name. You can’t do var g = eval(String(f)). Use the function name.
    3. Be careful. The function f will have access to all your local variables.

    For example:

    eval(String(getAdder()));
    
    alert(add(2, 3));
    
    function getAdder() {
        return function add(a, b) {
            return a + b;
        };
    }
    

    You can see the demo here: http://jsfiddle.net/5LXUf/

    Just a thought – instead of evaluating the function object why not just call it? That’ll give you your stack trace and it’s much simpler and safer (the function won’t have access to your local variables).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java-JSF Web Application on GlassFish, in which I want to use
I have web application of which major part is javascript. I request images from
I have a web application which process the data collected from different client machines
This is a conceptual question. I have a client (mobile) application which needs to
I have a simple web application in which I make a call to a
I have web application which we deployed in a production . We have separate
I have a web application which uses the globalization values being passed from sql
I have a web application which needs to perform a file copy operation and
I have one web application which I have been working for some time.I am
I have a web application which contains both secure (SSL) and non-secure pages. A

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.