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 6629983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:20:19+00:00 2026-05-25T22:20:19+00:00

I have never encountered a situation where I needed eval() . Often times, people

  • 0

I have never encountered a situation where I needed eval().

Often times, people say that the [] property accessor makes eval() redundant.

Actually, isn’t the execution of a pain statement exactly the same thing as pushing it as an argument into the eval() function. What is it actually used for?

Can you provide examples of when it might be useful to use eval()?

  • 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-05-25T22:20:20+00:00Added an answer on May 25, 2026 at 10:20 pm

    eval is something of a hybrid between an expression evaluator and a statement executor. It returns the result of the last expression evaluated (all statements are expressions in Javascript), and allows the final semicolon to be left off.

    Example as an expression evaluator:

    foo = 2;
    alert(eval('foo + 2'));
    

    Example as a statement executor:

    foo = 2;
    eval('foo = foo + 2;alert(foo);');
    

    One use of JavaScript’s eval is to parse JSON text, perhaps as part of an Ajax framework. However, modern browsers provide JSON.parse as a more secure alternative for this task.

    source

    With that in mind the only real reason I can see you wanting to use eval() is for executing user input.. but that leads to serious security risks… so in short I would say eval() (in javascript at least) has become a mute function; replaced by the many specific functions that would have invoked you to use eval() in the past.

    Another idea.
    You could possibly use it to execute pure js being returned by ajax

    your server could pass back a string containing “alert(‘hello world’);” and you could eval(returnData);.

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

Sidebar

Related Questions

On Windows I have a problem I never encountered on Unix. That is how
I have encountered a problem that I have never seen before. Usually, when I
I encountered an interesting thing today that I have never noticed before. It appears
Here's a software design question I've encountered several times and have never found an
I'm having a strange issue that I've never encountered before. I have a partial
I have used COALESCE numerous times but I suppose I never encountered this particular
I can honestly say I've never encountered this one before: I have two .ascx
I am having a strange issue that I have never encountered in the past
OK, for those who have never encountered the term, a quine is a self-replicating
I have done this many times and have never seen this. I have an

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.