Suppose you have two JavaScript codes:
Except for fine performance, both should get the same output.
The difference is that if the variable isMorning is true, call the function morningGreeting() or the function morningGreeting() always calls and branches within it.
if(isMorning) morningGreeting();
function morningGreeting(){
console.log('Good morning!');
}
morningGreeting();
function morningGreeting(){
if(isMorning) return;
console.log('Good morning!');
}
In general, which code is better in terms of serviceability and readability?
Some people may say that it doesn't matter as long as the project is unified.
I'd like to hear your opinion.
console.log('Good morning!'); I think running
depends on whether isMorning
is false or not.
If this is the case, I think it would be better to run it in function in terms of module strength.
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
619 Uncaught (inpromise) Error on Electron: An object could not be cloned
916 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.