+ 1

See description...

function x() // function expression {console.log(2+1);} // function statement Is this correct?

30th Apr 2019, 1:18 AM
radicalNoobSaibot
radicalNoobSaibot - avatar
5 ответов
+ 1
Correct but not a good practice. Opening at the same line as function keyword Indentation code block properly. Closing at same indentation level as its pairing opening. If you are using IDE on computer, IDE will highlight the pairing { for you when you hover; If you are coding on SoloLearn mobile app only, add a remark "this bracket closes... (which function)" https://code.sololearn.com/Wj2n3Cx4R7ua/?ref=app
30th Apr 2019, 1:23 AM
Gordon
Gordon - avatar
+ 1
I had to double check to see why it was a bad practice, then I squint and see the wrapped curly braces around console. It's safe to say if you can't read something in one go, it's not a good one.
30th Apr 2019, 1:29 AM
Lord Krishna
Lord Krishna - avatar
0
Gordon, is not declaring the variable not good practice? Or is it the empty parameters? Or maybe console.log? Let me know... And thank you for your answer: I've been trying to differentiate expressions from statements for about two days now. I've acquired the practice of documenting my code -- it helps a lot.
30th Apr 2019, 1:30 AM
radicalNoobSaibot
radicalNoobSaibot - avatar
0
I agree Gordon: I only placed my curly braces in a seperate line for the sake of this question specifically.
30th Apr 2019, 1:32 AM
radicalNoobSaibot
radicalNoobSaibot - avatar