How to use Vanilla JavaScript to listen for and emit events

How to use Vanilla JavaScript to listen for and emit events

Today I’ll teach you how to listen for and emit events using only JavaScript and the DOM. If you are a Web Developer, you may be aware that everything begins with events, such as moving, clicking, and keying, but how about developing your own events to perform your tasks? Fire a click event We can emit a click event at any place in the front-end context; let’s create a basic page to demonstrate this: ...

July 5, 2023 · William Sena
JavaScript bind() function: How to Handle Context

JavaScript bind() function: How to Handle Context

In this article, I’ll show you how to handle context in JavaScript and how to use curried functions to help you improve your programming skills. Let’s move on to the bind function. Bind function The bind() function in JavaScript is used to create a new function to change the context, for closed friends this. The new function can be called with a new context and arguments, making it useful for curried functions. ...

March 30, 2023 · William Sena
You must use Prettier as the code format for your TypeScript or JavaScript project.

You must use Prettier as the code format for your TypeScript or JavaScript project.

I used to format my JavaScript by hand or with the Editor’s default format, and sometimes I found myself disapproving the format code I had created a few minutes before; if this sounds familiar, it’s time to change. When I was a child, I spoke as a child, I understood as a child, I thought as a child: but when I became a man, I put away childish things. — 1 Corinthians 13:11 KJV. ...

March 22, 2023 · William Sena
JavaScript: What is an Immediately Invoked Function Expression (IIFE)?

JavaScript: What is an Immediately Invoked Function Expression (IIFE)?

When I first saw this pattern in a book called JavaScript High Performance, I fell in love with how it was used and began to use it for everything. I had no idea about JavaScript tricks like “===”, Date, “for/var”, prototypes, and others at the time, but this book changed the way I wrote JavaScript code. I can say that book was worth every penny, but I now remember to land on someone and never return 😭. ...

March 8, 2023 · William Sena
Unlock NGINX hidden powers with Javascript module (NJS)

Unlock NGINX hidden powers with Javascript module (NJS)

According to W3Techs Statistics, NGINX was the most popular HTTP Server until March 2022, while Javascript remains the language most-utilized language among its developers. I’m a big fan, so why not combine them? Nothing new, guys,** NGINX** released the first NJS version in 2016, and He caught my attention. I tried to use it, but I found it difficult to get things to work because the project is still in the works, unlike the Lua module. ...

October 23, 2022 · William Sena