A small problem with js

I just don"t quite understand why you won"t report an error in this way. What does it mean to write like this?

let fn = () => {a: 1}
fn()

that"s why a: 1 won"t report an error. What does it mean? Solve ~ crab!

Apr.03,2021

ES6 arrow function: http://es6.ruanyifeng.com/-sharpdo.

In the code

above, the original intention was to return an object {a: 1}, but because the engine thought the curly braces were a block of code, a: 1 was executed. At this point, a can be interpreted as the label of the statement, so the statement actually executed is 1 position, and then the function ends with no return value.


Let me translate it for you


:

let fn = () => ({a: 1})
fn()

because if you don't add parentheses, the curly braces are the scope symbol of the method body rather than the literal quantity of the object. It must be wrong for you to put a a: 1 directly in the method body. Just add parentheses

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b4057b-348b7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b4057b-348b7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?