Skip to main content
InterviewHubPRO
Section Overview
Q218

Question 218 of 536

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

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

What is the difference between uneval and eval

junior LevelMost AskedCode ExampleEvent LoopPrototypes

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"