Skip to main content

4 posts tagged with "javascript"

View All Tags

· 3 min read
Sivabharathy

A closure in JavaScript is a feature where a function retains access to its lexical scope, even when the function is executed outside that scope. Closures allow functions to "remember" the variables from their original context, enabling powerful and flexible programming patterns.

In simpler terms, a closure is created when an inner function accesses variables declared in its outer function, even after the outer function has finished executing.

· 4 min read
Sivabharathy

JavaScript is often described as single-threaded, non-blocking, asynchronous, and concurrent. While these terms can seem daunting, the underlying concepts are straightforward when you understand how the Event Loop, Call Stack, Microtask Queue, and Macrotask Queue work together. In this article, we’ll demystify these concepts with explanations and code examples.


The Call Stack

The Call Stack is where JavaScript keeps track of function execution. It operates on the "last in, first out" (LIFO) principle. When a function is called, it’s added to the top of the stack. Once the function finishes execution, it’s removed from the stack.

· 4 min read
Sivabharathy
  • Prefer const over let. Ditch the var

Using const means that once a variable is assigned, it cannot be reassigned. Preferring const will help you to not be tempted to use the same variable for different uses, and make your code clearer. If a variable needs to be reassigned, in a for loop, for example, use let to declare it. Another important aspect of let is that a variable declared using it is only available in the block scope in which it was defined. var is function scoped, not block-scoped, and shouldn't be used in ES6 now that you have const and let at your disposal

· 5 min read
Sivabharathy

What is a data structure ?

In software engineering, a data structure is an organisation to coordinate, oversee and store data in a way that permits proficient access and change.

banner image All the more exactly, a data structure is an assortment of data esteems, the connections among them, and the capabilities or tasks that can be applied to that data.

These definitions could sound a piece theoretical from the start, yet consider it. In the event that you've been coding for a brief period, you probably utilised data structures previously.