Why use eval in Javascript challenges yet it's not recommended to be used? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why use eval in Javascript challenges yet it's not recommended to be used?

In Javascript challenges have noticed the use of eval function n yet it's not recommended. This is bad for learners as they will resort to using the function.

8th Jun 2017, 5:22 AM
Chad Tims
Chad Tims - avatar
4 Answers
+ 12
why is using eval so bad? eval is a very powerful function. There are times where it's perfectly appropriate. The problem is that no tutorial really shows how and when to use it.
8th Jun 2017, 5:36 AM
Kamil
Kamil - avatar
+ 12
well, I've not played JS in quite some time and I don't know the quizzes you are talking about, but sometimes quizzes in general show bad practices in order to demonstrate why they are bad... I agree with Kamil - eval is powerful, but one thing you should never do with it is to run it with user's input, without checking what the input holds 😉
8th Jun 2017, 6:08 AM
Nikolay Nachev
Nikolay Nachev - avatar
+ 8
@Nikolay just like python's eval()
8th Jun 2017, 8:16 AM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar
13th Jun 2017, 11:24 AM
Benneth Yankey
Benneth Yankey - avatar