FrontendDeveloper.in

JavaScript question detail

What is the purpose of uneval

The uneval() is an builtin function which is used to create a string representation of the source code of an Object. It is a top-level function and is not associated with any object. Let's see the below example to know more about it's functionality,

var a = 1;
uneval(a); // returns a String containing 1
uneval(function user() {}); // returns "(function user(){})"

The uneval() function has been deprecated. It is recommended to use toString() for functions and JSON.stringify() for other cases.

function user() {}
console.log(user.toString()); // returns "(function user(){})"
Back to all JavaScript questions
Get LinkedIn Premium at Rs 399