DEV Community

Simc Dev
Simc Dev

Posted on • Edited on • Originally published at cmsinstallation.blogspot.com

Features of JavaScript - That You Should Know

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:

Image description

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:

Image description

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:

Image description

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:

Image description

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:

Image description

Top comments (8)

Collapse
 
pengeszikra profile image
Peter Vivo

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.

export function * watchNavigationStartSaga () {
  yield all([
    take(WEB_GL_READY),
    take(START_DISCOVERY),
  ]);

  yield delay(100);

  while (true) {
    const {fullRange} = yield select();
    yield putAction(CHANGE_TIMELINE, zoom(fullRange, 1));
    yield take(START_DISCOVERY);
  }
}
Enter fullscreen mode Exit fullscreen mode

advice: You can use redux-saga without redux by: use-redux-saga

I also wrote a game flow example used by generator function: Regexp Poker ... quite unfinished but show how things is going.

Collapse
 
machineno15 profile image
Tanvir Shaikh

Very Helpful, i thought Elective Chaining only works in typescript, Thanks for This.

Collapse
 
devsimc profile image
Simc Dev

Cheers

Collapse
 
pengeszikra profile image
Peter Vivo

Elective Optional Chaining still work in JS.

Collapse
 
joolsmcfly profile image
Julien Dephix • Edited

Unless Iโ€™m mistaken itโ€™s called optional chaining.

Collapse
 
jonrandy profile image
Jon Randy ๐ŸŽ–๏ธ

Might want to actually show how to use generator functions

Collapse
 
razor867 profile image
Wahyu Arya Pambudi

thanks, this adds insight for me

Collapse
 
devsimc profile image
Simc Dev

Cheers