FrontendDeveloper.in

ECMAScript question detail

Function.toString()

Functions have an instance method called toString() which return a string to represent the function code. Previous versions of ECMAScript removes white spaces,new lines and comments from the function code but it has been retained with original source code in ES2020.

function sayHello(message) {
let msg = message;
//Print message
console.log(`Hello, ${msg}`);
}

console.log(sayHello.toString());
// function sayHello(message) {
//       let msg = message;
//       //Print message
//       console.log(`Hello, ${msg}`);
//   }
Back to all ECMAScript questions
Get LinkedIn Premium at Rs 399