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

What is the purpose of uneval

Advertisement

728x90

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,

javascript
1var a = 1;
2
3uneval(a); // returns a String containing 1
4
5uneval(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.

javascript
1function user() {}
2
3console.log(user.toString()); // returns "(function user(){})"

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 40

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
210of476