Posts

Showing posts from June, 2022
Image
  Var vs Let in Javascript Many developers who used to write code on Javascript don’t care about the big differences in use between Var & Let and maybe they don’t even know.                                                               What are the differences between Let and Var? Basically, it’s one of the most asked questions in the job interviews, even among the developers them selfs. var and let are both used for variable declaration in javascript but the difference between them is that var is function scoped and let is block scoped.   So let’s define the differences by defining how they behave differently in many roles: Scoping: Before ES6 (2015), JavaScript had only Global Scope and Function Scope. ES6 introduced the let keyword which defined a Block Scope in JavaScript That means that the variables defined using let inside a {} Block can’t be accessed from outside the block. While variables defined using the var inside a {} Block could be accessed from outside the block. Def