javascript - what's the purpose of eval function? -


i know function gets string of valid javascript expression or statements , evaluate expression or execute statements, why need pass code function execution instead of writing code in script?

let's have functions: makecheckbox(), makeradio() , makeselect() (theoretically). want call function user's activity (for example menu click). can make if, else if , on, can make switch, can eval , make like:

eval('make'+userchoose.charat(0).touppercase()+string.slice(1)+'()'); 

where userchoose 1 of options: radio,checkbox or select, first-char-uppercased first , concatenated make (before) , () (after), @ end calls 1 of functions.

this not practice because in large projects can't find callings function, because they're "hidden behind" eval, it's way.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -