Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Calculate string value in javascript, not using eval

let str = "12/5*9+9.4*2"

let res1 = eval(str)
console.log('res1:', res1)

let res2 = (new Function('return '+str)())
console.log('res2:', res2)
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript excel column letter to number 
Javascript :: sorting number with coma datatable 
Javascript :: add value to the top of an array in js 
Javascript :: template literal syntax not working 
Javascript :: odd even condition with ternary operator 
Javascript :: gms2 object method 
Javascript :: why use currying 
Javascript :: jquery find child of parent sibling 
Javascript :: click button when press enter javascript 
Javascript :: react redux actions must be plain objects 
Javascript :: axios pass params 
Javascript :: MongooseError: Operation `users.insertOne()` buffering timed out after 10000ms node js 
Javascript :: Making font weight bold by passing value in React.js 
Javascript :: adonis count with where 
Javascript :: Check if local storage is used or empty 
Javascript :: js window redirect 
Javascript :: redirect function in javascript 
Javascript :: select first 3 letters js 
Javascript :: server express node js 
Javascript :: javascript line break 
Javascript :: javascript set readonly property 
Javascript :: xml to json api in asp.net 
Javascript :: react media query hook 
Javascript :: react overflow scroll 
Javascript :: graphql float 
Javascript :: how to create a button with react 
Javascript :: angular add object to array 
Javascript :: javascript remove a specific item from an array 
Javascript :: js multiply string 
Javascript :: loopback model properties default 
ADD CONTENT
Topic
Content
Source link
Name
5+7 =