+ 1
explain about why {...} use here ?
let {log} = console ; log("what?"); Result => what? i don't understand well this code...
4 Answers
+ 5
console.log added to object
In every calling of object log function gets data and printing it!
+ 3
let {log} = console;
is equivalent to
let log = console.log;
This technique is called object destructuring.
+ 3
This statement release methods to functions or properties to value(s):
Examples:
const {log: LOG= alert} = console; //
LOG('OUTPUT'); // will consoled if there is a log method in console object if it is not will use the alert replace it log: LOG is the function name in constant
+ 1
thank for responds guys