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(a, b) {
return a+b;
}
Arrow Function
const addNumbers = (a, b) => {
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;
};
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);
Comments
Post a Comment