Sunday, November 17, 2024
Google search engine
HomeLanguagesJavascriptJavaScript uneval() Function

JavaScript uneval() Function

The uneval() is an inbuilt function in Javascript that is used to create a string representation of the source code of an Object. 

Syntax:

uneval(object)

Note: This function has been DEPRECATED and is no longer recommended.

Parameters: It accepts an object which may be a JavaScript expression or statement. 

Return Value: It returns a string that represents the source code of the given Object.

JavaScript examples to show the working of this function:

Example 1: If the number is passed to the function uneval() then the function will return a string with the value of the object passed. 

javascript




let obj = 2;
console.log(eval(obj));


Output:

2

Example 2: If the char is passed to the function uneval() then the function will return a string with the value of the object passed. 

javascript




let obj = '2';
console.log(uneval(obj));


Output:

"2"

Example 3: If the number is passed to the function uneval() then the function will return a string with the value of the object passed. 

javascript




let obj = uneval(function func() { return 'Geeksforneveropen'; });
let func1 = eval(obj);
console.log(func1());


Output:

neveropen

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 the Firefox web browser.

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments