Results 1 to 6 of 6

Thread: Eval function in javascript

  1. #1
    Join Date
    Apr 2008
    Posts
    240

    Eval function in javascript

    I am not a book lover and don't like to deep study with books.Eventually,I choose the internet to solve my problems regarded PC or programming .I am practicing on Java script and need to know more about the function named EVAL in java script,what's the use of this function and in which segment of the program can be used.
    Please tell me whatever the practical knowledge you have just share with me .

    Thanks.

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    Eval function in javascript

    There are so many JavaScript programmers are aware about the EVAL command in java script which is used in the programming around since JavaScript 1.0 and ECMA-262 but some of the programmer used it.

    I am going to show you a quick tour on this function.We will also look at how EVAL can support you when you gonna use some dynamic component in your Web applications.

    The eval() function is supported with the following browsers which is very popular and mostly used in market -

    1- Internet explorer
    2- Mozilla fire-fox
    3- Opera
    4- Google Chrome

  3. #3
    Join Date
    Feb 2008
    Posts
    1,852

    Eval function in javascript

    Eval Function in java script -

    The eval() function generates and/or executes a string which is written in JavaScript.

    primarily, Eval() consider if the parameter which will be passed in the parenthesis of the eval function is a valid string or not then after eval() parses the string looking for JavaScript code. If it succeeded to get any JavaScript code then that would be executed.

    The formal syntax for the eval function in java script is as follows -

    Code:
    eval(string)
    You can put it with any statement in java script which needs to perform the display operation.

  4. #4
    Join Date
    Jan 2008
    Posts
    1,521

    Eval function in javascript

    I am going to show you a program which is based and structured on the calculation of two or more variables with the help of eval() in java script programming -

    Code:
    <script type="text/javascript">
    
    eval("num1=10;num2=20;document.write(num1*num2)");
    document.write("<br />" + eval("2+2"));
    document.write("<br />" + eval(num1+17));
    
    </script>
    And the output would be as follows-

    200
    4
    27

  5. #5
    Join Date
    Apr 2008
    Posts
    1,948

    The real power of EVAL

    The Actual functionality of this command is its capability to work with data which is not considered during load time.

    Suppose, a user-entered some data.The EVAL function relieves the string which is provided by the user and manipulates and then returns the result. If one of them is acceptable .Apart from this ,the function provide you the facility to execute it during run time of the program.

    For example,if you have some specific segment of your program which needs to perform the calculation and you are unaware of what the user will input.In this situation,you can perform the calculation to store the input values in variable.

  6. #6
    Join Date
    May 2008
    Posts
    2,012

    Re: Eval function in javascript

    This is one of the example for EVAL command in a auto-generated function which is constructed through MacroMedia's DreamWeaver Editor.This code is a representation of real time application -

    Code:
    function jmp_Menu(trgt,selectObj,rstr)
    
    {
    
        EVAL(trgt+".location='"+selectObj.options[selectObj.selectedIndex].value+"'");
    
        if (rstr) selectObj.selectedIndex=0;
    
    }
    * trgt value is used to load the selected URL
    * Document - current window
    * Parent - parent document
    * newwinAn separate window entitled by newwin
    * parent.mainframe located as a sibling Frame/Iframe identified by mainframe
    * Top specifies the top level item listed in current window
    Last edited by Katty; 02-03-2010 at 06:01 PM.

Similar Threads

  1. Passing XSL value to javascript function
    By Steadfast in forum Software Development
    Replies: 6
    Last Post: 13-05-2010, 11:51 PM
  2. c# function equivalent to gettime function in javascript
    By Omaar in forum Software Development
    Replies: 4
    Last Post: 10-03-2010, 10:44 PM
  3. Javascript isNull function
    By Chrisch in forum Software Development
    Replies: 3
    Last Post: 11-11-2009, 02:51 PM
  4. JavaScript Sleep Function
    By DARIELLE in forum Software Development
    Replies: 3
    Last Post: 29-06-2009, 09:30 AM
  5. JavaScript function help
    By suseman in forum Software Development
    Replies: 3
    Last Post: 26-05-2009, 05:11 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,997,397.49217 seconds with 16 queries