dcsimg
Results 1 to 6 of 6

Thread: What is the eval() function in JavaScript?

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2019
    Posts
    5

    What is the eval() function in JavaScript?

    What is the eval() function in JavaScript?

  2. #2
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,164

    Re: What is the eval() function in JavaScript?

    https://developer.mozilla.org/en-US/...l_Objects/eval

    IE) it runs a string as actual code
    Code:
    eval("alert('test')");
    would show an alert dialog. It is very dangerous to use, as the documentation shows.

  3. #3
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,563

    Re: What is the eval() function in JavaScript?

    I typed exactly three words into google: javascript eval function...
    this is what I get back.
    https://www.google.com/search?q=java...+eval+function

    It's not rocket science. It isn't that difficult. I just takes a couple of seconds to type some key words into google, and google will even do some predictive typing for you and you don't even need to type it all in. Half-way through the word "eval" google suggested "javascript eval function" as a possible result.

    Half of being a developer is being able to do research and looking things up.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    CT
    Posts
    17,864

    Re: What is the eval() function in JavaScript?

    eval is a powerful part of JavaScript - it can create "new" code within your JS script.

    For example, I use SlickGrid's for displaying grids of data (and doing maintenance within that grid). Similar to the VB6 FlexGrid...

    At any rate, I allow super-users to "create" formula's to run on change events on the grid, so that you could, for example, re-calculated other cells in the grid. I store these formula's in database tables and load them into the JS world when the grid is loaded.

    Code:
    eval("g_objGrid[intGO].formula = function (currentRow, currentCell, item) {" + strCellChange + "\n}");
    if (strBeforeCellEdit.length != 0) {
        eval("g_objGrid[intGO].beforeeditformula = function (currentRow, currentCell, item) {" + strBeforeCellEdit + "\n}");
    }
    if (strGridLoad.length != 0) {
        eval("g_objGrid[intGO].gridloadformula = function (currentRow, currentCell, item) {" + strGridLoad + "\n}");
    }
    eval is similar to Exec('some sql string') in MS SQL.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,709

    Re: What is the eval() function in JavaScript?

    I think you mean MS SQL Server T-SQL.

  6. #6
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    CT
    Posts
    17,864

    Re: What is the eval() function in JavaScript?

    Quote Originally Posted by dilettante View Post
    I think you mean MS SQL Server T-SQL.
    Strange comment - obviously I was suggesting SQL syntax which would imply T-SQL, certainly not PL/SQL...

    At any rate - to show a recent use of EXEC() that I placed into a nightly process that imports date stamped text files..

    Code:
    If @LoadTable<>0
    Begin
        Create Table #LicCert (Username varchar(100), LCType varchar(100)
                            , LCNAme varchar(100), Number varchar(100)
                            , EffDate varchar(100), ExpDate varchar(100))
    
        Set @BC='Bulk Insert #LicCert From ''h:\eLogicDownloads\Archive\Downloaded_'
                            +@DateYMD+'\Certifications'+@DateYMD+'.txt'''
    
        Exec(@BC)
    That would be T-SQL code in an MS SQL Server Stored Procedure
    Last edited by szlamany; Nov 20th, 2019 at 09:11 AM.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width