JavaScript, generally required for ReactJS

let and const: 


    Different ways of creating variables.

    Some variables never change, for that, we use const -> constant variables.

    For a changeable variable, use let -> variable variables


const:

    const myName = "Ayush";
    console.log(myName);
    myName = "Amit"; -> This will show an error as the constant value don't change

let:

    let myRollNo = 33;
    console.log(myRollNo);

    myRollNo = 17;
    console.log(myRollNo);
    

Arrow Function:

    Normal Function

        function addNumbers(ab) {
            return  a+b;
        }    

    Arrow Function     

        const addNumbers = (ab=> {
            return a+b;
        }

    Some features of arrow function:

        If there is exactly one argument in function, we can avoid round brackets around it
            const Increment = a => {
              return a + 1;
            };

      If there is one statement to return, we can avoid curly braces around it            
            const Decrement = a => a-1;

Export and Import:

    Use to import content from one file to other.

    Example of Exporting file content

        const ExportingHere = {
            name: "Ayush",
            course: "B.Tech"
        }
        export default ExportingHere;

    Example of Importing file content

        import ExportingHere from "./ExportingHere";
        console.log(ExportingHere);

    We can import and export multiple file components. The importing of multiple file contents is called named import.

Comments