Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How is "eval()" harmful?

KB15
Giga Guru

I was using a reference from SNGuru and found that the code they provided comes up as a warning:

https://www.servicenowguru.com/system-ui/adding-fields-service-catalog-checkout-screen/

find_real_file.png

What would be the downsides and is there a better way to code this?

1 ACCEPTED SOLUTION

TrevorK
Mega Sage

I could try and explain why many people do not like eval() and some of the downsides, but there are many others who do a better job of explaining it than I do:


https://www.nczonline.net/blog/2013/06/25/eval-isnt-evil-just-misunderstood/


How evil is eval? — JavaScript, JavaScript…


Tommy Hodgins's response to Why is using `eval` considered bad in JavaScript? - Hashnode



There are many other links, but that should hopefully give you some background information on eval() because there is some contention to its use.


View solution in original post

1 REPLY 1

TrevorK
Mega Sage

I could try and explain why many people do not like eval() and some of the downsides, but there are many others who do a better job of explaining it than I do:


https://www.nczonline.net/blog/2013/06/25/eval-isnt-evil-just-misunderstood/


How evil is eval? — JavaScript, JavaScript…


Tommy Hodgins's response to Why is using `eval` considered bad in JavaScript? - Hashnode



There are many other links, but that should hopefully give you some background information on eval() because there is some contention to its use.