InterviewHubPRO
Section Overview
Q218

Question 218 of 521

Part 4: Prototypes, Object Methods & Event Loop (174 - 253)

42%
JavaScript Internals (521 Qs)•Part 4: Prototypes, Object Methods & Event Loop (174 - 253)

What is the difference between uneval and eval

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
  var msg = uneval(function greeting() {
    return "Hello, Good morning";
  });
  var greeting = eval(msg);
  greeting(); // returns "Hello, Good morning"