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.
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
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!
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.assertexpects 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.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
very much agree on the whole array part! unnoticed mutations can be such a pain in the ass!
Reminds me of GIGO - Garbage In Garbage Out đ
if (obj.property)does not equalif (property in obj)whenobj.propertyis falsy. And I really thinkarr.lengthshould be considered immutable. Good point though!Thanks, it was a good read, bookmarked, and followed!
No offense, but I don't think these codes are going to be useful
No problem! I will try my best to write better blogs!
That was a nice read! Liked, bookmarked and followed, keep the good work! đ
Thanks đ you can even star my current project github.com/rovelstars/reejs for support đ
Thanks for the information! Will try to keep the next blog better!
Good Work đđ