2coffee.dev

  • Maybe Data Type
    • javascript
    • node.js

    Maybe Data Type

    Promises in JavaScript are certainly familiar to anyone. A Promise represents a "promise" that when a function is called, it will definitely return a value in the future. Whether it is resolved or rejected, we can predict the likelihood of one of the two occurring. And one thing is for sure, both cannot occur at the same time. If you study Promise more closely, you will see...

    1 month 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...

    11 months ago

  • Premium
    Hello

    Me & the desire to "play with words"

    Have you tried writing? And then failed or not satisfied? At 2coffee.dev we have had a hard time with writing. Don't be discouraged, because now we have a way to help you. Click to become a member now!

    Have you tried writing? And then failed or not satisfied? At 2coffee.dev we have had a hard time with writing. Don't be discouraged, because now we have a way to help you. Click to become a member now!

    View all
  • 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

  • Beside Error Handling, Creating Errors with Error Objects Is Equally Important
    • error
    • error handling

    Beside Error Handling, Creating Errors with Error Objects Is Equally Important

    A while ago, I wrote an article on Error Handling Techniques in Node.js, focusing on how to catch errors and handle them effortlessly. In this article, we'll temporarily set aside those techniques and dive deep into the topic of "throwing" errors and how to "catch" them effectively. I believe many of us, including myself, have thrown an error that looks like this...

    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

  • What are Higher-order functions (HOF)? The benefits of using them in your projects.
    • javascript

    What are Higher-order functions (HOF)? The benefits of using them in your projects.

    I still remember when I first read an article about Higher-order functions, there was a certain level of confusion. Being new to the field, the theoretical aspect was quite difficult to grasp. At that time, I understood the concept but couldn't visualize its practical applications. It took me a while to realize that this was something I had been using regularly all along! There are already many articles about Higher-order functions on the internet...

    1 year ago