In the previous post, Synchronous vs Asynchronous Programming, we discussed the difference between Synchronous and Asynchronous programming in JavaScript. In this article, we will discuss what are Callbacks in JavaScript.
Callback is a function that is passed as an argument to another function and its execution is delayed until that function in which it is passed is executed.
Meaning, if I pass a function, let’s say function1
to another function, i.e., function2
,then function1
will not be executed until function2
is executed.
Callbacks are a fundamental part of Functional Programming, and you may be already using them without knowing; methods like…
In this article, we will discuss What Synchronous Programming is? What Asynchronous Programming is? And whether JavaScript is Synchronous or Asynchronous?
Many developers struggle to understand topics like Callbacks, Promises, and Async/Await, one of the reasons may be not understanding the actual need and core logic behind them.
Having a good grasp of this topic can help you understand them more easily.
This can be better explained with the help of an example.
Imagine you gave your friend a set of tasks:
What your friend now…
In this article, we will be discussing what dangerouslySetInnerHTML
is, how it is used, what the differences are between dangerouslySetInnerHTML
and innerHTML
, and a real project where it proves to be useful.
dangerouslySetInnerHTML
is an attribute under DOM elements in React.
According to the official documentation, dangerouslySetInnerHTML
is React’s replacement for using innerHTML
in the browser DOM.
This means that if in React if you have to set HTML programmatically or from an external source, you would have to use dangerouslySetInnerHTML
instead of traditional innerHTML
in Javascript.
In simple words, using dangerouslySetInnerHTML
, you can set HTML directly from React.
In this post, we are going to build a pokemon index using Pokemon API in plain Javascript. First, let’s discuss what this project is about, there will be a search bar where users can come and search for a pokemon and after the search, pokemon with its image and stats, as a result, will be shown. So, the functionality is pretty basic but you using this project as a base can tweak and make your own version of this project and add it to your portfolio.
The full version is deployed at https://poke-mon.now.sh/
This project is inspired by Chris on…
Almost everything in Javascript is an object, whether it’s an array or a function. In this post, we’ll learn three different ways to create objects in JavaScript:
A JavaScript object literal is a comma-separated list of name-value pairs wrapped in curly braces. Object literals encapsulate data, enclosing it in a tidy package.
Object literal property values can be of any data type, including array literals, function literals, and nested object literals.
Consider a scenario in which you have to put different variables inside an object. One way of doing it is:
In this post, we are going to discuss hoisting. We’ll be discussing what it is and why it’s important for you to know as a Javascript developer or programmer.
This article is the first of many small articles discussing key areas and terms in Javascript, such as call stack, callback, promise, async, etc.
Before we start discussing what hoisting is, let us first look at a simple example:
Pretty straightforward: I declared a variable, initialized some value to it, and then logged it in the console.
Now let's look at the definition of hoisting:
Simply put, it means no…
Sets are a new object type included in ES6 that allow the creation of collections of unique values. The values in a set can be either simple primitives like strings and integers or more complex object types like object literals or arrays. Think of sets as an array with no repeated elements.
There are many instances where we have an array containing many elements that we want to convert to a unique array. While it can be done by brute force on the array, checking elements, using loops, distinct callback method, etc., the best method is using set().
Syntax:
new…
In this piece, we are going to discuss closures and lexical scoping in JavaScript. Understanding closures leads to a better understanding of programming itself. If you are planning on becoming a professional programmer, questions regarding closures and their applications are widely asked during technical interviews and can be really helpful to you.
If you are a JavaScript Developer, chances are you already using closures and just don't know it. There are so many complex examples out there that just confuse you when you try to learn closures, so I’ll be using the simplest examples I could find and by the…
Functions are one of the key components in programming. They are defined to perform a specific task and can be called again and again to execute. The main difference between functions in Javascript and other programming languages is that in javascript functions are of first-class objects, which means that they behave like objects and can be assigned to variables, array, and other objects.
This post discusses three different ways to define functions:
Probably the most common way to declare a function. Let’s look at its syntax:
Function Declaration comprises of…
When we talk about technological advancements in the last 3 to 5 years names like Artificial Intelligence, Chatbots, Augmented Reality, Machine Learning, etc. comes to our mind, but what this list is missing is “Cloud Computing” , even today there are many people, even some developers who have no idea what this actually means and how its changing the traditional way of computing, also there is still a wide misconception that cloud is another name for drive, storing data over the internet, well storage is a part of cloud computing but its more than that, so much more than that…