Posts

Showing posts with the label Hoisting

SOLID / DRY principles

In software development, Object-Oriented Design plays a crucial role when it comes to writing flexible, scalable, maintainable, and reusable code. There are so many benefits of using OOD but every developer should also have the knowledge of the SOLID principle for good object-oriented design in programming. The SOLID principles are designed to help developers design robust, maintainable applications. The five SOLID principles are: Single-responsibility principle - Function and classes should have one job. Open–closed principle - Classes and functions should be open for  extension but not for modification. Liskov substitution principle - Child class can replace parent class Interface segregation principle - This principle is the first principle that applies to Interfaces instead of classes in SOLID and it is similar to the single responsibility principle. It states that “do not force any client to implement an interface which is irrelevant to them“. Here your main goal is ...

Hoisting in Javascript

"Java script putting function declarations into memory before it executes any code segment is that it allows you to use a function before you declare it in your code Hoisting is a JavaScript mechanism where variables and function declarations are moved to the top of their scope before code execution. T his means that no matter where functions and variables are declared, they are moved to the top of their scope regardless of whether their scope is global or local Note : JavaScript only hoists declarations, not initialization . If a variable is declared and initialized after using it, the value will be undefined. Ex :  num = 100; // Initialization console.log(name) // 100 var  num; //  Declaration   console.log(name)  // Undefined var  num = 100; //  Declaration   Here only declaration will go on the top not initialization. let Vs var The main difference between  let  and  var  is that scope of a variable defined with  let ...

Popular posts from this blog

Why do we need callbacks

Difference between localStorage and sessionStorage

Scope in javascript