Posts

Showing posts from September, 2022

Javascript Basic Concepts that Every Frontend Developer Should Know about

Image
 Hi There,      I am Roshan and in this post, we are gonna see some of the basic concepts in Javascript and probably next-generation Javascript that help a lot while writing code in any of the Javascript frameworks like React, Angular, and a lot more. let & const let  and const  basically, replace var . Earlier we were using var to declare variables in Javascript. We can use let instead of var as let is block scoped and var is function scoped. var can allow redeclaration of variables but let don't.   const - we can use const when we plan on never re-assigning this variable. let number = 10 ; const PI = 3.14 ; ES6 Arrow Functions Arrow functions are a different way of creating functions in JavaScript.  Arrow function syntax may look strange but it's actually simple. which you could also write as: function display ( name ) { console . log ( name ); } becomes:  const display = ( name ) => { console . log ( name ...

React import and export code from different Javascript files

Image
Exports & Imports In React projects, We split our code across multiple JavaScript files - so-called modules. You do this, to keep each file/ module focused and manageable. To still access functionality in another file, you need to export  (to make it available) and import  (to get access) statements. There are two different types of exports: default which is unnamed and named exports: default  export default ...;  named export const someData = ...;  We can import default exports like this: import someNameOfYourChoice from './path/to/file.js' ; Named exports have to be imported by their name: import { someData } from './path/to/file.js' ; A file can only contain one default and an unlimited amount of named exports. You can also mix the one default with any amount of named exports in one and the same file. When importing named exports, we can also import all named exports at once with the following syntax: import * as nameOfYourChoice from './path/t...