I have a variable (var a='10+8-2')
.
Now i want mathematical operation in the string, That means var a=16
.
Asked
Active
Viewed 42 times
0

Apon Ahmed
- 53
- 1
- 9
-
If you want function, `substr` or `substring`. What is the question? – Tushar Sep 03 '15 at 04:50
-
1Your title seems to be asking a completely different question than the text of the question. What does evaluating a formula have to do with the PHP function `substr()`? – Barmar Sep 03 '15 at 04:51
1 Answers
1
javascript has eval
for this operation
Try like this
var a=eval('10+8-2');
but eval is evil during minification
Read this before using it

Community
- 1
- 1

Anik Islam Abhi
- 25,137
- 8
- 58
- 80