Javascript Concepts for React JS

Let & Const

Different ways of creating variables. In ES 6 (javascript version ) two new keywords were introduced. var will also work in your all javascript versions.
Before ES6, the below is allowed for var. You can change the value of a variable anytime.

In ES6 we can use let instead of var to do the same thing.

But, if you use const and try to change the value of const after assignment, you will get an error in browser console. So you can assign value to a const only once.

Output :

Arrow functions

A different syntax for creating JavaScript functions.
Here is the syntax to write function before ES6

Lets see how to write Arrow functions in ES6

Exports & Imports (Modules)


The main idea behind modules is to allow you to import and export different sections of code from different files into other files. This helps you to organize your code to understand later and makes maintenance much easier. The export statement is used when creating JavaScript modules to export functions, objects or primitive values from the module so they can be used by other programs with the import statement.

There are three types of exports

  • Named Exports (Zero or more exports per module)
  • Default Exports (One per module)
  • Hybrid Exports

Named Export :

Named Export

This is the test for named EXPORT

I Am still editing this post, i will keep adding more to this. Please feel free to ask me if you need a specific topic or concept in this post.