JavaScript | uneval() with Examples
The uneval() is an inbuilt function in JavaScript which is used to create a string representation of the source code of an Object.
Syntax:
uneval(object)
Parameters: It accepts an object which may be a JavaScript expression or statement.
Return Value: It returns a string which represents the source code of the given Object.
Code #1:
If the number is passed to the function uneval() then the function will return a string with the value of the object passed.
<script> var obj = 2; document.write(eval(obj)); </script> |
Output:
2
Code #2:
If the char is passed to the function uneval() then the function will return a string with the value of the object passed.
<script> var obj = '2'; document.write(uneval(obj)); </script> |
Output:
"2"
Code #3: If the number is passed to the function uneval() then the function will return a string with the value of the object passed.
<script> var obj = uneval(function func() { return 'Geeksforgeeks'; }); var func1 = eval(obj); document.write(func1()); </script> |
Output:
GeeksforGeeks
Difference between eval() and uneval() functions:
The uneval() function returns the source of a given object whereas the eval() function evaluates that source code in a different memory area.
Note: Above codes will run only in Firefox web browser.
Recommended Posts:
- JavaScript | weakSet.has() with Examples
- JavaScript | console.log() with Examples
- JavaScript | weakMap.has() with Examples
- JavaScript | unescape() with examples
- JavaScript | parseFloat() with Examples
- JavaScript | weakSet.add() with Examples
- JavaScript | weakMap.set() with Examples
- JavaScript | parseInt() with Examples
- JavaScript | getPrototypeOf() with Examples
- JavaScript | typedArray.map() with Examples
- JavaScript | _.reduceRight() with Examples
- JavaScript | typedArray.name with Examples
- JavaScript | typedArray.every() with Examples
- JavaScript | typedArray.of() with Examples
- Javascript | _.reduce() with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



