Do you know these Javascript concepts before you learn React ?
Introduction
React is a javascript library and if you know some javascript basics and have build some projects , you will learn react very smoothly and didn't have to bother learning react.
There are some concepts in javascript , if you learn before jumping to react library then react will seemed to be as plain javascript and you only need to learn some particular concepts in react that are specific to the library which are only few.
1. Scoping
This is the one basic but important concept in javascript where before ES6 has introduced , it has only Global scope and Function scope means variable declare in the function cannot be access in outside environment and gets local to the functions . After ES6 , block {} scope has also introduced where the variable declared in the block cannot be access outside the block.
2. Callbacks
Javascript functions are executed in the sequence they are called not in the sequence they are defined which introduced the callback concept . These functions passed as an argument in the function and called after the end of the execution which gives the tendency in the function to call other function . By it's name it already says I will call back later !!
3. Reference Vs Value
In Javascript knowing the difference between the reference and value is making the lives in the coding not in hell . Reference values like object , arrays and functions whose value are not stored but the address ( reference ) stored in the memory . So with the equals to (==) it will always gives false . But the primary datatype in javascript like string , Boolean , number whose only value is stored in the memory and can easily be compare in the conditional statements.
4. Type Coercion And (== / === )
You need to understand the implicit conversion from one datatype to another .Like , Number to String , String to Number and Boolean to Number and look the difference at what operation does number can convert into string or vice versa .
Also, the double equals to sign only checks for the value but the triple equals to sign also check for the datatype which also need to be considered when doing coding in javascript
5. Advance Array Methods
There are some advance array methods which used in react frequently and you must have known these topics at the core and what parameters we need to pass. The methods like array.map() , array.filter() , array.reduce() , array.findOne() . These are the most used methods of array that are used in react.
6. Mutability
Mutability is the core meat in the javascript which means some datatypes can be mutate in the existing memory without creating new one . Primitive data type are non mutable because they cannot be mutate like object with a dot notation but reference values like arrays ,objects and functions can be mutate without creating new one in the memory.
7. Short Circuiting
Short circuiting in the javascript is to just to implement some one liner conditions and get the returned result you wanted . Like with the && operator after the condition can execute the statement which is written after this operator . Learning ternary operatory in the javascript can also make you code better in react .
8. Asynchronous Code
Await , promises and fetch requests and async statements are important to learn for sending http request to the backend by which you can get the response and can do the later operations on it. Javascript is a synchronous thread and execute line by line but there is some code in the javascript which needs some wait to execute . So , with promises and asynchronous code we can run other large tasks during some task is performed instead of waiting to finish the task.
9. General Concepts of Module
React is all about the ecosystem where the packages contribute to the project and can include the different functionalities . React is form with different component so we need export and import statement to make the code reusable and modular . These import and export statement can also be used in javascript as many beginners don't know about it and get jump directly to react.
10. Concept of ES6
There are many concepts of ES6 which are used so much now a days and is so much convenient and productive to use in the daily life . Some concepts include destructuring , spread operator , Advance array methods , Advance string methods , For/of loop , rest parameter , arrow functions etc.
Conclusion
These are some concepts in javascript which if you know them before learning react , it will become very easy for you to adapt the library and you can easily make project in react without struggling in comparison to developers that directly jump to react without learning javascript , they struggle the most in coding and get daily beginner javascript bugs in the react code.
Comments
Post a Comment