+ 1

Javascript doubt

Because this code has output: 10 let{log} = console; log("10");

10th Oct 2019, 6:32 PM
Stiven 98
Stiven 98 - avatar
2 odpowiedzi
+ 6
Brayan Pinilla look that code like this: let log = console.log; log("10"); Mira el código así: let log = console.log; log("10"); let {log} = console Primero verifica si console tiene una propiedad log(un método en este caso) y luego asigna esa propiedad a una variable let log.
10th Oct 2019, 6:48 PM
Kevin ★
+ 2
Destructuring assignment is a ES6 syntax. console.log is the log method on the console object. With { } in assignment, it detaches the method from console object. You can even rename the method in object destructuring, like this: https://code.sololearn.com/WrdB29dw8NxT/?ref=app You can find more about it in Morpheus's JS Fact #050 https://www.sololearn.com/post/45092/?ref=app You can find the whole Morpheus's JS Fact here : https://code.sololearn.com/Wyr76080kKxS/?ref=app
11th Oct 2019, 9:19 AM
Gordon
Gordon - avatar