Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please type your username.

Please type your E-Mail.

Please choose an appropriate title for the post.

Please choose the appropriate section so your post can be easily searched.

Please choose suitable Keywords Ex: post, video.

Browse

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Logo

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Navigation

  • Home
  • About Us
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • About Us
  • Contact Us
Home/ Questions/Q 3152

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise Latest Questions

Author
  • 61k
Author
Asked: November 26, 20242024-11-26T12:04:13+00:00 2024-11-26T12:04:13+00:00

The Next Gen JavaScript

  • 61k

The next gen javascript simply refers to ES6 and later versions of javascript. Most common question developers ask before using ES6 is the compatibility of the language with modern browsers. If you take a look at the compatibility chart you'll find that we are totally safe to use ES6 syntax in our code.

Well if you take a closer look to the chart you may find some unsupported/partially supported features but the most popular features of ES6 are supported by all the modern browsers like Chrome, Firefox and Safari.

If you are targeting old browser like IE11 you can still use ES6 syntax with the amazing babel compiler. Babel is called a compiler because it compiles ES6 code to the ES5 so that as long as the browser support ES5 you can use ES6 code without running into any problems.

Why ES6?

The full list of ES6 features can be found here but lets take a look at its most popular features.

The let and const keywords

These are two new ways of creating variables. Variables created with let keyword are usable only within the scope of the block in which they are created while const keyword can be used to create constant (value which never changes).

 function letAndConst() {     let fruit = "apple";     if (true) {         let fruit = "orange";         console.log(fruit);     }     console.log(fruit); } letAndConst();  // Output: // orange // apple 
Enter fullscreen mode Exit fullscreen mode

Arrow functions

The feature which I love the most. It solves the problem of “this keyword” by keeping its context. It also provides us a shorter and cleaner way of defining our functions.

// Single line arrow function const es6Function = () => console.log("Single line arrow function");  // Multi line arrow function const es6Function = () => {     console.log("Multi line");     console.log("Arrow function"); }  // If there's only single arguement you can omit parantheses  const es6Function = arg1 => {     console.log(arg1); } 
Enter fullscreen mode Exit fullscreen mode

Classes

ES6 introduces the class keyword so that no need to use prototype inheritance when creating a class.

// ES6 class Animal {     constructor() { }     sound() { console.log("Animal Sound"); } }  class Dog extends Animal {     sound() {         super.sound();     } }  // ES5  var Animal = function () { }; Animal.prototype.sound = function () { }; 
Enter fullscreen mode Exit fullscreen mode

Array/Object destructuring

Another lovely syntax which makes life so much easier

//ES5 var firstName = person.firstName; var lastName = person.lastName; var age = person.age;  console.log(firstName, lastName, age);  //Output: // John Doe 27   // ES6  var { firstName, lastName, age } = person; console.log(firstName, lastName, age); //Output: // John Doe 27  
Enter fullscreen mode Exit fullscreen mode

The Spread Opreator (...)

Another syntax to help you write less and fast code

 const numbers = [1, 2, 3, 4] const newNumbers = [...numbers, 5, 6, 7]  console.log(newNumbers);  //Output: // [1, 2, 3, 4, 5, 6, 7] 
Enter fullscreen mode Exit fullscreen mode

Exports

This feature helps us write modular code. Modular code means javascript files which can be accessed by other javascript files. We get two types of exports here.

  • The default export
  • The targeted export

The default exports the whole javascript file as default

const roundNumber = num => Math.round(num);  export default roundNumber;  // In another file we can say that   import anything from "./relativePathToTheFile"; 
Enter fullscreen mode Exit fullscreen mode

The targeted export exports the specific functions or variables from a javascript file.

// Targeted Export const roundNumber = num => Math.round(num); var name = "John" const double = (number) => {     return number * 2; }  export const language = "JavaScript";  // In another file we can say   import language from "./relativePathToTheFile"; // Remember to use the same name  //you used while exporting the constant 
Enter fullscreen mode Exit fullscreen mode

Conclusion

I will strongly recommend the use of ES6 syntax in personal and professional projects because:

  • Less Code to write
  • Easily readable and maintainable
  • Faster

The features mentioned above are some of most popular features. You should visit ES6 Features and you can find all the awesome features of ES6.

This is first time in my life writing a post so sorry for any mistakes.
Suggestion are always welcome ❤.

javascriptwebdev
  • 0 0 Answers
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question

Stats

  • Questions 4k
  • Answers 0
  • Best Answers 0
  • Users 2k
  • Popular
  • Answers
  • Author

    ES6 - A beginners guide - Template Literals

    • 0 Answers
  • Author

    Understanding Higher Order Functions in JavaScript.

    • 0 Answers
  • Author

    Build a custom video chat app with Daily and Vue.js

    • 0 Answers

Top Members

Samantha Carter

Samantha Carter

  • 0 Questions
  • 20 Points
Begginer
Ella Lewis

Ella Lewis

  • 0 Questions
  • 20 Points
Begginer
Isaac Anderson

Isaac Anderson

  • 0 Questions
  • 20 Points
Begginer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help

Footer

Querify Question Shop: Explore Expert Solutions and Unique Q&A Merchandise

Querify Question Shop: Explore, ask, and connect. Join our vibrant Q&A community today!

About Us

  • About Us
  • Contact Us
  • All Users

Legal Stuff

  • Terms of Use
  • Privacy Policy
  • Cookie Policy

Help

  • Knowledge Base
  • Support

Follow

© 2022 Querify Question. All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.