Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

alternative of eval

let userInput = "2+4";
let result = Function("return " + userInput)(); // which is same as "return 2+4"
console.log(result)
Comment

javascript eval alternative


parseInt(3) + parseInt(3)
Comment

PREVIOUS NEXT
Code Example
Javascript :: array method 
Javascript :: react navigation header title 
Javascript :: error: Error: Unable to resolve module `crypto` from `node_modulescrypto-jscore.js`: crypto could not be found within the project. 
Javascript :: how to select a dom element in react 
Javascript :: Find the count of a letter in a string 
Javascript :: passport middleware check if authenticated 
Javascript :: Updating a nested object in a document using mongoose 
Javascript :: redirect to another path react 
Javascript :: enzyme airnb 
Javascript :: an array of functions 
Javascript :: AJAX - The XMLHttpRequest Object 
Javascript :: javascript add method to a class 
Javascript :: super keyword in javascript 
Javascript :: react-drag-drop-files open twice 
Javascript :: javascript date range 
Javascript :: notify js 
Javascript :: slot vuetify js 
Javascript :: js days to hours 
Javascript :: javascript set query parameters in url 
Javascript :: connect redux 
Javascript :: err handling express 
Javascript :: Importing From Export Default Module 
Javascript :: TypeError: Converting circular structure to JSON 
Javascript :: http_proxy 
Javascript :: html css js interview questions 
Javascript :: javascript syntax of throw statement 
Javascript :: javascript get the last array element 
Javascript :: get last item in array js 
Javascript :: vue create component 
Javascript :: random chars javascript 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =