You can use the JavaScript Expression Evaluator library, which allows you to do stuff like:
Parser.evaluate("2 ^ x", { x: 3 });
Or mathjs, which allows stuff like:
math.eval('sin(45 deg) ^ 2');
I ended up choosing mathjs for one of my projects.
More Related Contents:
- How to force JS to do math instead of putting two strings together [duplicate]
- How can I extract a number from a string in JavaScript?
- Why does JavaScript handle the plus and minus operators between strings and numbers differently?
- What’s the best way to convert a number to a string in JavaScript?
- Javascript Thousand Separator / string format [duplicate]
- Check whether an input string contains a number in javascript
- Remove insignificant trailing zeros from a number?
- JavaScript string and number conversion
- How to convert a String containing Scientific Notation to correct Javascript number format
- How can val() return Number?
- JavaScript adding a string to a number
- Javascript: How to retrieve the number of decimals of a *string* number?
- Show a leading zero if a number is less than 10 [duplicate]
- What is JavaScript’s highest integer value that a number can go to without losing precision?
- Why is one string greater than the other when comparing strings in JavaScript?
- string.charAt(x) or string[x]?
- How can I capitalize the first letter of each word in a string using JavaScript?
- How can I process each letter of text using Javascript?
- Calculate date from week number in JavaScript
- How do I shuffle the characters in a string in JavaScript?
- JavaScript exponents
- Is there a way to calculate 3D rotation on X and Y axis from a 4×4 matrix
- How can I send the “&” (ampersand) character via AJAX?
- Making a javascript string sql friendly
- Trim specific character from a string
- How do I round a number in JavaScript?
- Prepend text to beginning of string
- Are double and single quotes interchangeable in JavaScript?
- Javascript Number Prototype Set Value Directly [duplicate]
- javascript – Convert array to string while preserving brackets