DEV Community

Cover image for JavaScript more efficient and readable code for make a calculator with only 20 lines with
Asad Ullah
Asad Ullah

Posted on

JavaScript more efficient and readable code for make a calculator with only 20 lines with

Eval Function for a Calculator

Click Here for visit the calculator and its code
This is very very best way to improve and make efficient for our code. The eval() function is very helpful to make efficient, readable and maintainable. As we know about eval() function the eval() is a function property of the global object. The argument of the eval() function is a string. It will evaluate the source string as a script body, which means both statements and expressions are allowed. It returns the completion value of the code. For expressions, it's the value the expression evaluates to.

Comment me if you have impressive by this calculator.

Click Here for visit the calculator and its code

Top comments (2)

Collapse
 
trungho profile image
Hồ Phước Trung

I don't even dare look back at what I wrote before :'( my html css js calculator

Collapse
 
habibasarwar786 profile image
HabibaSarwar786

Thank you so much. I've try your code. Its working. This is so amazing code its such a clean code. Thank you So Much Sayyed Asad Ullah.