JavaScript is a front-end language, the most utilized language nowadays by developers to design web pages or web applications. Developers use this language to make a transcendent framework to make their work more attractive. ECMAScript version(ES6+) of JavaScript is the latest version now to use and there are lots of advanced functions.
Features of JavaScript
1. Style Console Log
you know that? you can style the console log by using JavaScript. To customize the console log you need to add CSS on it to get the console log. If you want to print the source code you need to add %c before the code and then add console.log() after it. But it requires CSS to variable to execute it.
If you want to customize the variable in comparison to others you need to use %c and console.log() before it. And add CSS properties as you want in it.
Let's see the example:
2. Use Shorthand Operators
ES6 has a shorthand to define operators in a short way. And this is an operator that no one can talk about simply because they don't know about it. This operator makes your work easy and fast. And it looks very clean and neet to read and understand.
Let's see the example:
3. Elective Chaining
Chaining ?. is used to check properties before ?. if it's null or undefined then it returns undefined otherwise its returns the value.
Developers have a lot of work and projects to complete before a time. Source code has large objects, nested loops, containers, for that to check the property.
Let's see the example:
4. Use Generator Function
This is a function that similar to common functions the only difference between them is Generator function stops the execution on a particular line when you want and continue when you want. To create the generate function you need to use * after keyword of function.
Let's see the example:
5. Use in Keyword
in keyword is used to check the properties are available in an object or not. After using this keyword you can get the true or false value its depend on the value that available in an object or not.
Let's see the example:
Top comments (8)
Generator Function
Is the really underestimated part of javascript. I used frequently in redux-saga which is based on generator functions, becauose that give a declarative code block which can be used for great async coding.
I also wrote a game flow example used by generator function: Regexp Poker ... quite unfinished but show how things is going.
Very Helpful, i thought Elective Chaining only works in typescript, Thanks for This.
Cheers
ElectiveOptional Chaining still work in JS.Unless Iโm mistaken itโs called optional chaining.
Might want to actually show how to use generator functions
thanks, this adds insight for me
Cheers