2coffee.dev

  • process.nextTick, setImmediate, and setTimeout
    • javascript
    • node.js

    process.nextTick, setImmediate, and setTimeout

    Anyone who delves deeper into Node.js may have seen articles distinguishing between setTimeout, setImmediate, and process.nextTick. I am no exception! At first, I tried to understand how to use them by reading articles and even Node documentation. However, they were mostly theoretical...

    3 weeks ago

  • A Few Useful Functions in Node.js Util Module
    • node.js
    • javascript

    A Few Useful Functions in Node.js Util Module

    Node.js encompasses a range of components that come together to form a JavaScript runtime environment. In our series on Node.js Architecture - Introduction to Node.js, we explored the various components that make up Node.js and their respective functions. One of the built-in modules in Node.js is `util`, which, in my opinion, deserves more attention. The `util` module comprises a collection of small utility functions that can be helpful in certain situations. In this article, we will delve into some of these functions...

    2 months ago

  • The Concept of Immutability in JavaScript
    • javascript
    • node.js

    The Concept of Immutability in JavaScript

    Variables are an essential component in most programming languages. When we talk about variables, we often think of a syntax that includes a keyword, variable name, data type, and its initial value. Variables - as the name suggests, their values can be changed through assignment. Changing the value of a variable allows programmers to reuse variable names, save memory, and...

    9 months ago

  • Promise: How to Use and Some Notes!
    • promise
    • javascript
    • node.js

    Promise: How to Use and Some Notes!

    It would be a glaring omission not to talk about Promise in JavaScript. In fact, there have been many articles written about Promise, which you can find through Google or occasionally come across in a programming-related community. But because Promise is an important concept and everyone has a different way of explaining it, I still decided to write this article. When I first learned JavaScript, Promise was the most confusing thing. I thought I understood it and knew how to use it, but in reality, there were still many long and painful stumbles...

    1 year ago

  • Point-Free Style in JavaScript
    • javascript
    • node.js

    Point-Free Style in JavaScript

    My initial encounter with this style left me quite puzzled. What are toJSON, handleResult, and handleError here? Are they functions, and if so, where are their parameters? How can they run without ending with () to call the function? Or at the very least, where are their input parameters? Numerous questions popped up in my mind, but at that time, there was no one to explain it to me. What you encounter frequently becomes familiar, so I started emulating this style, implicitly thinking, "Oh, I'll just write it like this, and it will work." It wasn't until later...

    1 year ago

  • Some Ways to Write More Readable Code in JavaScript/Node.js
    • javascript
    • node.js

    Some Ways to Write More Readable Code in JavaScript/Node.js

    What I believe many programmers aspire to is writing code that is easy to read and understand. There is plenty of evidence, such as the numerous Design Patterns that have been introduced to guide people in solving problems the way many still do. However, that's not all there is to it. Writing comprehensive code depends on each individual programmer. We have various tools to aid in source code editing in many ways, such as formatting, colors, display interfaces, debugging support, allowing us to choose according to our preferences or collaborate with teams. In addition, there are still rules in place for team members to adhere to.

    1 year ago

  • From Callbacks, Promise to Async/Await in JavaScript/Node.js Asynchronous Processing
    • javascript
    • node.js

    From Callbacks, Promise to Async/Await in JavaScript/Node.js Asynchronous Processing

    JavaScript made its first appearance nearly 30 years ago as a new programming language of its time. It certainly needed some time to stabilize and gain widespread use. Until now, we can't deny the success of JavaScript, as it appears everywhere in the web world. Furthermore, it has expanded beyond web browsers to accomplish even more. A product of technology never stops evolving. Over the years, JavaScript has continuously evolved, introducing more useful features and addressing its inherent limitations. TC39 is a group established within the ECMA association with the goal of standardizing JavaScript while actively developing and expanding it.

    1 year ago

  • What Are Prototypes in JavaScript? Why Are They Important?
    • javascript

    What Are Prototypes in JavaScript? Why Are They Important?

    If you're familiar with object-oriented programming languages, classes are the clearest syntax for defining a new object. JavaScript is also considered an object-oriented programming language, but if you're an early JavaScript developer from around a decade ago, it didn't have the class syntax. Instead, it supported inheritance through prototypes, which had a somewhat different syntax compared to OOP in most other languages and wasn't highly regarded for its powerful OOP features. In recent years, ES6 introduced the class keyword...

    1 year ago

  • What is Asynchronous Programming? Why is JavaScript a language for asynchronous programming?
    • javascript
    • other

    What is Asynchronous Programming? Why is JavaScript a language for asynchronous programming?

    JavaScript is a language for asynchronous programming - that's something everyone knows. Asynchronous operations are most evident in asynchronous functions, which do not immediately return a result but instead return it at some point in time. If you come from a background of PHP, Go, or even Java... you may have not heard or be confused about what asynchronous programming is. You may also wonder why JavaScript is a language for asynchronous programming and whether it brings any benefits or limitations to the language...

    1 year ago

  • debounce, throttle, and once - three functions to enhance user logic!
    • javascript
    • node.js

    debounce, throttle, and once - three functions to enhance user logic!

    Finding solutions to problems is a crucial skill for programmers. Usually, the more we work, the more experience we gain. At this point, when faced with similar problems, we can quickly find a solution. There are many ways to learn from experience, one of which is to search and read many articles and documentation online. Sometimes the knowledge we acquire may not be immediately necessary, but it can be useful at some point. Or at least...

    1 year ago