JS Coding Questions Logo
JS Coding Questions
#214💼 Interview💻 Code

What is the difference between uneval and eval

Advertisement

728x90

The uneval function returns the source of a given object; whereas the eval function does the opposite, by evaluating that source code in a different memory area. Let's see an example to clarify the difference,

javascript
1var msg = uneval(function greeting() {
2  return "Hello, Good morning";
3  });
4
5var greeting = eval(msg);
6
7greeting(); // returns "Hello, Good morning"

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 44

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
214of476