Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #23678

Re: Expresson evaluation in javascript

From Joao Rodrigues <groups_jr-1@yahoo.com.br>
Newsgroups comp.lang.javascript
Subject Re: Expresson evaluation in javascript
Date 2014-03-25 18:40 -0300
Organization Aioe.org NNTP Server
Message-ID <lgst3k$hrc$1@speranza.aioe.org> (permalink)
References <62248b63-802b-4e9c-b3d3-d31c5003a24d@googlegroups.com>

Show all headers | View raw


Em 25/03/2014 15:24, jonas.thornvall@gmail.com escreveu:
> In python i beleive mathematical expression can be directly
> evaluated, if in correct form.

In modern browsers, we may use the JavaScript console, the Developer 
Tools (press F12), or even the browser's address bar (e.g. javascript: 2 
+ 3)

In Node.js, we can use the command line.

>
> Javascript do not have eval?

There is a built-in eval function in JavaScript (JS), but it may be 
evil, or not. See 
<http://www.nczonline.net/blog/2013/06/25/eval-isnt-evil-just-misunderstood/>

The resemblances between Python and JS are misleading. For instance, in 
Python we have different types of Numbers, and Python Lists look like 
Arrays in JS, but indexing in Python is more flexible than in JS. E.g. 
arr[-1] in Python returns the last item in the list, but in JS it would 
return undefined, unless there was a property named "-1" in the Array 
Object (arr).

>
> If not, how do one go ahead evaluate something with two constant
> operands but where the operator is a variable?
>
> z=*;   x=3z5
>
> z=/    x=3z3
>
> z=+    x=3z3
>
> z=-    x=3z3
>

These are invalid assignments in JS.

In the other hand, there are Punctuators in JS +=, -=, *=, =/, etc.

>
> Will there be a eval function in future javascript?
>

See above.

-- 
Joao Rodrigues (J.R.)

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Expresson evaluation in javascript jonas.thornvall@gmail.com - 2014-03-25 11:24 -0700
  Re: Expresson evaluation in javascript jonas.thornvall@gmail.com - 2014-03-25 11:43 -0700
    Re: Expresson evaluation in javascript jonas.thornvall@gmail.com - 2014-03-25 11:44 -0700
  Re: Expresson evaluation in javascript Danny <dann90038@gmail.com> - 2014-03-25 14:04 -0700
  Re: Expresson evaluation in javascript Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2014-03-25 18:40 -0300
  Re: Expresson evaluation in javascript Christoph Michael Becker <cmbecker69@arcor.de> - 2014-03-25 23:49 +0100
    Re: Expresson evaluation in javascript jonas.thornvall@gmail.com - 2014-03-25 22:43 -0700
      Re: Expresson evaluation in javascript jonas.thornvall@gmail.com - 2014-03-25 23:29 -0700
        Re: Expresson evaluation in javascript Jim T. <x@y.z> - 2014-03-28 11:48 -0500
          Re: Expresson evaluation in javascript jonas.thornvall@gmail.com - 2014-03-28 10:03 -0700
            Re: Expresson evaluation in javascript Jim T. <x@y.z> - 2014-03-28 13:12 -0500
            Re: Expresson evaluation in javascript "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-03-28 18:33 +0100
              Re: Expresson evaluation in javascript jonas.thornvall@gmail.com - 2014-03-28 10:50 -0700
                Re: Expresson evaluation in javascript jonas.thornvall@gmail.com - 2014-03-28 10:59 -0700
                Re: Expresson evaluation in javascript "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-03-28 20:38 +0100
                Re: Expresson evaluation in javascript "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2014-03-29 19:49 -0700
                Re: Expresson evaluation in javascript Ed Jay <edMbj@aes-intl.com> - 2014-03-29 10:53 -0700
      Re: Expresson evaluation in javascript "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2014-03-29 19:45 -0700
        Re: Expresson evaluation in javascript jonas.thornvall@gmail.com - 2014-03-30 09:21 -0700
        Re: Expresson evaluation in javascript jonas.thornvall@gmail.com - 2014-03-30 09:24 -0700
          Re: Expresson evaluation in javascript "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2014-03-30 21:19 +0200
          Re: Expresson evaluation in javascript "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2014-03-30 14:20 -0700
  Re: Expresson evaluation in javascript John Harris <niam@jghnorth.org.uk.invalid> - 2014-03-26 14:58 +0000
  Re: Expresson evaluation in javascript "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2014-03-29 19:33 -0700
  Re: Expresson evaluation in javascript Norman Peelman <npeelman@cfl.rr.com> - 2014-03-30 05:01 -0400

csiph-web