DEV Community

Make it Short - Make it Better

Ren Hiyama on September 10, 2022

Hey there Fellow Javascript Coder! Whether you're a experienced programmer or just someone who just started with javascript basics, this list of ha...
Collapse
 
thecodingcrow profile image
thecodingcrow

very much agree on the whole array part! unnoticed mutations can be such a pain in the ass!

Collapse
 
renhiyama profile image
Ren Hiyama

Reminds me of GIGO - Garbage In Garbage Out 🙃

Collapse
 
tracygjg profile image
Tracy Gilmore

Hi Ren, An alternative to if(variable) console.log("True"); can be found as a method in the Console API., although the logic needs to be inverted.

console.assert expects at least two parameters; a Boolean assertion and a message (or any other data) you want to present.

So the alternative to the above code is console.assert(!variable, "True"). It is typically used to flag up when something went wrong but I have never seen it used in production code.

Collapse
 
renhiyama profile image
Ren Hiyama

You probably didnt see it in production code because many people know what assert does, including me! I just use console.log during testing and remove them when their logging work for testing is over

Collapse
 
naucode profile image
Al - Naucode

Thanks, it was a good read, bookmarked, and followed!

Collapse
 
mrcaidev profile image
Yuwang Cai

if (obj.property) does not equal if (property in obj) when obj.property is falsy. And I really think arr.length should be considered immutable. Good point though!

Collapse
 
renhiyama profile image
Ren Hiyama

Thanks for the information! Will try to keep the next blog better!

Collapse
 
devangtomar profile image
Devang Tomar

That was a nice read! Liked, bookmarked and followed, keep the good work! 🙌

Collapse
 
renhiyama profile image
Ren Hiyama

Thanks 👍 you can even star my current project github.com/rovelstars/reejs for support 🙃

Collapse
 
erfannvb profile image
Erfan • Edited

No offense, but I don't think these codes are going to be useful

Collapse
 
renhiyama profile image
Ren Hiyama

No problem! I will try my best to write better blogs!

Collapse
 
awcode0x profile image
AWCode0X

Good Work 👏👏