In recent years it has seen rapid improvements with the popularization of front-end frameworks and the creation of NodeJS.
1- Double bang
We all know about the single bang (!), which is used to negate the value placed after it, for example:
What most people don’t know about is the double bang (!!). Logically one might think that it simply stands for two bangs, which pretty much do nothing to the value but that’s not how they work.
The double bang gives back the boolean representation of the value next to it, for example:
Destructuring is actually a great name for what this is. Destructuring allows you to take all the contents of an array or object and place them inside another one by using ‘…’.
You can also destructure an object into multiple variables all at once like this
or you can destructure two arrays into a new joint array like this:
Console.log move over, a fancier king is in town.
The debugger keyword is great for when you feel like using console logs to debug your code, but you don’t really want to do that for all 10 variables you want to look at.
You can throw a debugger pretty much anywhere in your code and the browser will stop where you placed it.
At that point you can test anything that you have access to in that code block. Check the gif below:
4- Console.warn and Console.error
The lesser known cousins to console.log().
The two allow you to highlight the output to the console.
They might be useful if you have a lot out logs but you want to make sure that you see those when they happen.
This is how the console.warn() looks like
and this is how the console.error() looks like.
I am always learning about new development tricks as I go and I’ll make sure to share them with you as they come along.
What are some tricks and tips that you guys use?