I'm creating a map editor for my game, and I added feature which is adding script to map (textarea), then code writed by person which is editing a map is saved to variable, and then when this person save map, this variable is saved to JSON file as variable in Map object.
When map is loading in the game, this code is transforming into Function object and then it's launching.
My question is: Is there option to check is this string valid JavaScript, and if not alert("Error" + error) or something like that?
// Editor is only for developers, not for users, so I don't need to check it on server-side for safety

eval()return if string will be not correct?eval