teleren/devto huggingface dataset:
The Surprising Truth about Promises
Published: 2024-02-21 11:27:51

---
title: The Surprising Truth about Promises
published: true
description: 
tags: 
cover_image: https://miro.medium.com/v2/resize:fit:1400/format:webp/0*XSuWdYa8wYDgNltc
# Use a ratio of 100:42 for best results.
# published_at: 2024-02-21 11:21 +0000
---

As developers, we often work with promises and callbacks in our code. While they may seem similar at first glance, there are some important differences to keep in mind. In this article, we will explore these differences and gain a deeper understanding of how promises and callbacks work.

Through an execution order experiment, we will examine the task queue versus the microtask queue and how they impact the behavior of callback functions and promises. By the end of this article, we will have a clear understanding of the promise mechanism and the microtask queue, as well as how they differ from callback functions and the task queue.

**Key Takeaways**

- Promises and callbacks have important differences in how they execute in code.

- The microtask queue runs before the task queue, impacting the order of execution.

**The Experiment**

I setup an experiment to observe the execution order of promises and callbacks. The sample code below sets up a promise that logs a value and a callback function that uses setTimeout to log the same value.

```javascript
const promise = new Promise(resolve => {
  resolve('promise value');
});

setTimeout(() => {
  console.log('setTimeout value');
}, 0);

promise.then(value => {
  console.log(value);
});
```

At first glance, it may seem that the order of execution would be the same regardless of the order of the code. However, the order of execution is actually dependent on the type of queue being used.

Depending on the type of async mechanism you use, one of two queues are used internally

1. Microtask queue —or—
2. Task queue (aka Macrotask queue)

The main difference between the microtask queue and the task queue is that every task that’s been queued up in the microtask is run first, irrespective of how many items are there in the task queue.

To test this, I switched the order of the code and ran it again:

```javascript
setTimeout(() => {
  console.log('setTimeout value');
}, 0);

const promise = new Promise(resolve => {
  resolve('promise value');
});

promise.then(value => {
  console.log(value);
});
```

The result is still the same. From this it is clear that promises use the microtask queue, while callbacks like setTimeout use the task queue. This is why the setTimeout function always runs after the Promise.

Understanding this difference between the task queue and the microtask queue is important when working with promises and callback functions. It can help prevent unexpected behavior and ensure that our code runs as intended.

If you’re the kind of person that likes consuming tech content via videos, you can find a video of this on my YouTube channel.

YouTube link : [The Surprising Truth about JavaScript Promises](https://www.youtube.com/watch?v=6lsTRTUNHgk)

If you liked this article and you learned something, don’t be shy… show some love with a ❤️ 😀

Until next time…
𝗗𝗶𝗳𝗳𝗲𝗿𝗲𝗻𝗰𝗲 𝗯𝗲𝘁𝘄𝗲𝗲𝗻 * 𝗮𝗻𝗱 ** 𝗶𝗻 𝗳𝗶𝗹𝗲 𝗽𝗮𝘁𝗵𝘀?
Published: 2024-02-21 11:27:17


Single and Double Asterisks are both wildcard characters, but they have different meanings:
(Single Asterisk):
The * character matches zero or more characters within a single directory name or filename.
It's typically used to match multiple files or directories based on a specific pattern within a single directory level.
For example, file*.txt would match file1.txt, file2.txt, etc., within the same directory.

** (Double Asterisks):
The ** character, often used in glob patterns, matches zero or more directories and files, recursively.
It's typically used to match files or directories across multiple directory levels.
For example, root/**/*.txt would match all text files in any subdirectory of root, regardless of how deep they are nested.

In summary, * matches within a single directory level, while ** matches recursively across multiple directory levels.
Mofa Attestation UAE Unveiled: A Comprehensive Walkthrough
Tags: mofaattestation, uaeattestation, attestationsevices
Published: 2024-02-21 11:25:07

### Demystifying MOFA Attestation in the UAE

The What and Why of MOFA Attestation
Embarking on ventures in the UAE often necessitates the attestation of documents by the Ministry of Foreign Affairs (MOFA). This process verifies the authenticity of your paperwork, ensuring it aligns with the standards set by the UAE authorities.

Streamlining the Attestation Journey
The [**mofa attestation uae**](https://pecattestation.com/mofa-attestation) journey comprises several critical steps:

Notarization: Initiate the process by notarizing your documents with a Notary Public.
Authentication: Move on to the relevant government departments for further authentication.
MOFA Stamp: The final step involves obtaining the Ministry of Foreign Affairs' stamp, solidifying the document's legitimacy.
Navigating MOFA Attestation: A Step-by-Step Guide
1. Notary Public
Initiate the process by notarizing your documents through a Notary Public. This step provides the initial layer of authenticity.

2. Government Authentication
Navigate through the relevant government departments to ensure each entity authenticates your documents, providing a comprehensive validation.

3. MOFA Stamp
The ultimate validation comes with the MOFA stamp, underscoring the document's acceptance by the Ministry of Foreign Affairs.

MOFA Attestation UAE: FAQs
Q: How long does MOFA attestation usually take?

A: The timeline can vary, but it typically ranges from a few days to a couple of weeks.
Q: Can I handle MOFA attestation independently?

A: While feasible, many individuals opt for professional assistance to ensure accuracy and expedite the process.

In conclusion, understanding and completing the MOFA attestation process is vital for anyone looking to engage in international endeavors involving the UAE. Whether for personal or professional reasons, ensuring your documents are properly authenticated opens doors to various opportunities. Consider seeking assistance from reputable service providers to simplify and expedite the attestation process.
How to Display an RSS Feed in WordPress?
Tags: wordpress, beginners, tutorial, learning
Published: 2024-02-21 11:19:07

Is your WordPress blog missing RSS feeds from other websites?

In simple terms, RSS stands for Really Simple Syndication - a web feed format that lets you publish frequent updates of content on your WordPress site, such as blog posts, images, and news.

Publishers of blogs can benefit from RSS feeds because they can automatically associate their content with their sites. Readers benefit from web feeds by getting updates when new updates are posted on a website.

WordPress allows you to add RSS feeds to your website. We will learn how to display an RSS feed in WordPress in this guide.

### Steps to Display an RSS Feed in WordPress

1. Log in with your username and password to your WordPress admin dashboard.

2.In the **Appearance** section, click **Widgets**.

3.The RSS widget is next to Next.

4.Click on **Edit** to edit the **RSS** widget in **Current Widgets**.

5.You can enter the RSS feed URL, its title (optional), and check which items you would like to display (optional).

6.Once you have published the **RSS feed**, click on **Done** and **Save Changes**.

That’s it! The following is how you can display an RSS feed in WordPress.
Tres Pilares del Código Excelente: Comunicación, Simplicidad y Flexibilidad
Tags: spanish
Published: 2024-02-21 11:00:00

En el desarrollo de software, la excelencia a menudo se define por tres valores fundamentales: comunicación efectiva, simplicidad en la estructura y flexibilidad para la adaptación. Estos valores, aunque a veces parezcan contradictorios, se complementan entre sí en la práctica. Un código excelente es aquel que es robusto, fácilmente extensible, libre de complejidades innecesarias y comprensible para los desarrolladores.


## Comunicación
La programación no solo trata de hablar con la computadora; implica crucialmente la comunicación entre personas. Esto se traduce en código más claro, fácil de leer y con mejor relación costo-efectividad. Siempre piensa que tu código será mantenido por alguien que no eres tú. Programar sin considerar a los demás puede crear soluciones que, aunque brillantes en la mente del desarrollador, son confusas y difíciles de mantener para otros.

Hay un fuerte argumento económico para enfocarse en la comunicación durante la programación. La mayoría de los costos del software ocurren después de su implementación. En mi experiencia con la refactorización, me di cuenta de que pasé más tiempo entendiendo el código existente que escribiendo código nuevo. Por lo tanto, el código económico es aquel que es fácil de leer.

## Simplicidad
Eliminar la complejidad excesiva es vital. Esto permite a los programadores entender, usar y modificar el software más rápidamente. La complejidad excesiva reduce el valor del software, perjudica la ejecución correcta y complica los cambios futuros. Una parte esencial de la programación es evaluar lo que se ha hecho e identificar lo que es esencial y lo que no.

La simplicidad es subjetiva. Lo que es simple para un programador senior puede ser complejo para uno junior. Es saludable desafiar a los programadores, pero la complejidad innecesaria es un obstáculo. La búsqueda de la simplicidad fomenta la innovación.

## Flexibilidad
Dado que la mayoría de los costos de un sistema ocurren después de su implementación, facilitar los cambios es crucial. Mejorar la comunicación en el código aumenta su flexibilidad. Cuantas más personas puedan leer, entender y modificar rápidamente el código, mayor es la capacidad de adaptarse a cambios futuros. Considera que se unirán nuevas personas al equipo y cuanto más rápido entiendan el código, más rápidamente podrán contribuir y agregar valor al producto.

Elige estándares que promuevan la flexibilidad y traigan beneficios inmediatos, equilibrando desafíos y simplicidad.

## Conclusión
La armonía entre comunicación, simplicidad y flexibilidad es lo que define al código de alta calidad. Estos valores no solo facilitan el desarrollo y mantenimiento del software, sino que también son esenciales para el éxito y la sostenibilidad de los proyectos de software a largo plazo. Al integrar estos principios, los desarrolladores pueden crear soluciones más robustas, adaptables y eficientes, beneficiando a todo el equipo y, en última instancia, al producto final.
This Is The Best Advanced React Book I’ve Ever Read
Tags: react, webdev, beginners, javascript
Published: 2024-02-21 11:00:00

There are a lot of books/courses about React.

And I've read/purchased a lot of them over the past +5 years.

Unfortunately, I find many of them to be either bloated or too superficial - while still being expensive.

But recently, I have read a book called [**Advanced React**](https://www.advanced-react.com/) by @adevnadia that I believe is the best investment to make if you want to master React.

## For a few reasons:

**Reason #1: It covers everything you might find tricky as a junior dev and need to know to be a React expert.** The book discusses everything you need to learn to be really good at React, like how renders work, refs, context, and more. Back when I started over 5 years ago, I wish I had this book – it could've saved me from some confusing state issues.

**Reason #2: It is well-written with a lot of illustrations.** I love books that make hard stuff easy to understand, and this one does it really well. All the concepts are explained with nice and simple pictures.

**Reason #3: It stays practical.** If you are looking for a book that gets straight to the point without going off track, choose this one. You can use what you learn right away at work.

**Reason #4: It's concise.** With only 314 pages, it's a quick read. You get the essential information without unnecessary fluff.

**Reason #5: It's affordable.** At just $32, it's a bargain compared to other React resources.

If you want to master React, I can't recommend this book enough.

---

If you've read it, do you agree? What other book would you recommend for intermediate/advanced React developers?

And Don't forget to Drop a "💖🦄🔥".

If you like articles like this, join my **FREE** newsletter, **[FrontendJoy](https://frontendjoy.substack.com/)**, or find me on [X/Twitter](https://twitter.com/_ndeyefatoudiop).
today-new WP Tavern Launches Writer Hunger Games
Tags: beginners, tutorial, productivity, wordpress
Published: 2024-02-21 10:55:08


first of all: WPTavern is back - 

after some months the site is back again - serving the worldwide WP-Community. 

with excellent articles, with a supportiv attitude - and with discourse discourse _ its a a discourse of (WordPress) Univese and a universe of Discorse - both at the same time.
 
**today-new  WP Tavern Launches Writer Hunger Games**

https://wptavern.com/wptavern-launches-writer-hunger-games
cf: tl;dr Seven folx from the WordPress Community have been selected as finalists for two positions as writers for the Tavern.
May the odds be ever in your favor.
If you’ve been around the Tavern for a while you’re probably aware that it has been without a full-time writer or two since December 2023. Back in November, the Tavern’s last standing writer, Sarah ooding joined her predecessors Jeff Chandler and Justin Tadlock in announcing her departure. 
Matt Mullenweg later put the call out for those interested in becoming full-time writers. Hundreds applied and from that list, earlier this February, seven were chosen to participate in a public trial. 
Each travelled by train to a meeting where they were introduced to each other and then dropped into the middle of an arena with the only rule being to survive.
It may feel a bit like the Hunger Games have come to WordPress. But, behind the scenes, it’s a ton of enthusiasm and collaboration. After all, it’s for a platform and community we are all passionate about.
Hitting publish is stressful (at least for me), but, we’re excited about this chance. We’re eager to bring our unique views to Tavern readers and the wider WordPress community.
see more https://wptavern.com/wptavern-launches-writer-hunger-games

celbrate with us all the great success of bringing back wptavern.com
Need your feedback
Tags: survey, react, webdev, opensource
Published: 2024-02-21 10:45:10

👋 Hi front-end Developers,

I've conducted a survey to better understand how front-end developers perceive back-end development.

Would you be willing to take 3 minutes to answer this survey?

Link to the survey: 👉 [https://forms.gle/MTz1yXSjg7S6z1tQ9](https://forms.gle/MTz1yXSjg7S6z1tQ9)

Thank you for your help.
Website Development Company in Hisar
Tags: javascript, web
Published: 2024-02-21 10:45:09

Our website development company in Hisar offers top-notch services to help businesses establish a strong online presence. With a team of skilled developers and designers, we create custom websites that are visually appealing, user-friendly, and optimized for search engines. Whether you need a simple informational website or a complex e-commerce platform, we have the expertise to deliver a solution tailored to your specific requirements. Trust our reliable and efficient services to enhance your online visibility and drive more traffic to your business.
https://chiragtaneja.com/
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ixhmwcetpzgqdgssaxby.jpg)
Navigating Region Codes: What Consumers Need to Know
Tags: regioncode, countrycode, zipcode, apiaccess
Published: 2024-02-21 10:42:32

Region codes are a crucial aspect of the global distribution and playback of DVDs, Blu-ray discs, and video games. Understanding how region codes work and their implications for consumers is essential for making informed decisions when purchasing and using electronic media devices.

**Demystifying Region Codes**

**[Region code](https://ipstack.com/)** are digital locks embedded in DVDs, Blu-ray discs, and video games to control their distribution and playback in different parts of the world. Each region is assigned a unique code, and discs or games manufactured for one region may not play on devices sold in another region.

**Unraveling the Implications**

For consumers, region codes can present several challenges:

**Limited Compatibility:** DVDs, Blu-ray discs, and video games purchased in one region may not be playable on devices purchased in another region, limiting the flexibility of consumers who travel or purchase media internationally.

**Restricted Access:** Region codes can restrict access to certain content, preventing consumers from enjoying media that is only available in specific regions.

Inconvenience: Dealing with region codes can be inconvenient and frustrating, requiring consumers to either purchase multiple devices or seek alternative methods to bypass region restrictions.

**Strategies for Consumers**

Despite the challenges posed by region codes, consumers can take steps to navigate this issue:

**Research Before Purchase:** Before purchasing DVDs, Blu-ray discs, or video games, consumers should check the region code to ensure compatibility with their devices.

**Invest in Multi-Region Players:** Investing in multi-region DVD or Blu-ray players can provide consumers with the flexibility to play media from different regions without restrictions.

**Explore Software Solutions:** Software solutions are available that can bypass region coding on computers or gaming consoles, providing consumers with additional flexibility in playing media.

**The Future of Region Coding**

As technology continues to evolve, the relevance of region codes may diminish. Streaming services, for example, typically do not employ region coding, allowing consumers to access content from anywhere in the world with an internet connection. However, region coding remains prevalent in physical media and is likely to persist for the foreseeable future.

**Conclusion**

While **[region/country code](https://ipstack.com/)** may present challenges for consumers, understanding how they work and exploring strategies to navigate them can help consumers make the most of their electronic media devices. By staying informed and exploring alternative solutions, consumers can overcome the limitations imposed by region coding and enjoy their favorite media from around the world.
Fixing the 'Error Domain' Issue: Easy Step-by-Step Solutions!
Published: 2024-02-21 10:42:15

Struggling with the frustrating “[errordomain=nscocoaerrordomain&errormessage=could not find the specified shortcut.&errorcode=4](https://ssbytes.com/errordomainnscocoaerrordomainerrormessagecould-not-find-the-specified-shortcut-errorcode4/)” error on your Mac? You're not alone. This perplexing error message can be a real headache, especially when you're just trying to use a keyboard shortcut. But fear not—this guide is here to help you resolve the issue.

Understanding the Cause of the Error Message
In simple terms, the “errordomain=nscocoaerrordomain&errormessage=could not find the specified shortcut.&errorcode=4” error occurs when macOS encounters difficulty in locating or recognizing a keyboard shortcut. Here are a few potential reasons behind this annoyance:

1. The shortcut you're trying to use has been altered or removed altogether.
2. The application you're using hasn't been updated to support the latest shortcuts.
3. Multiple applications are conflicting over the same shortcut.
4. There might be issues with your keyboard input source configuration.
Data-Driven Tele-Sales Services in Malaysia
Published: 2024-02-21 10:41:14

Unlock qualified leads, nurture engagement, and close more deals with our expert [tele-sales services in Malaysia](https://www.denave.com/en-my/services/tele-sales/). 
We offer personalized and strategic approach to maximize lead generation, fosters client relationships, and propels business growth.
Explore a tailored solution designed to enhance your sales journey and drive success.
Start growing your business today !
Marine Research Nusa Penida
Tags: marineresearch
Published: 2024-02-21 10:26:04

[Marine Research Nusa Penida](https://www.sanctuaryecohero.org/), under Eco Hero Nusa, conducts groundbreaking scientific studies to understand and protect the marine biodiversity of Nusa Penida, Indonesia, aiding in the conservation of its fragile ecosystems and promoting sustainable management practices for marine resources. Join us in our mission to preserve the beauty and vitality of Nusa Penida's underwater world. Contact us now!
PudgyPenguins NFT Started new collection
Tags: pudgypenguins, nft, blockchain, cryptocurrency
Published: 2024-02-21 10:16:15

The path to Web3 mainstream adoption continues.   The new line of Pudgy Toys, with Pudgy World, is now available in 3,100
Visit [PudgyPenguins.com](http://plufferr.com)
@Walmart

No way, that's so cool! Congrats on the Walmart launch. Pudgy Penguins are on fire! 🔥
#PudgyPenguins #NFTCommunity #NFTGiveaway #blockchain #Web3
Capital One To Acquire Discover
Published: 2024-02-21 10:14:00

Today, Capital One Financial Corporation (NYSE: COF) and Discover Financial Services (NYSE: DFS) announced that they had finalized a deal in which Capital One will pay $35.3 billion in all-stock prices to acquire Discover.

Two businesses with a long history of achieving financial outcomes that are both appealing and robust, award-winning customer experiences, ground-breaking innovation, and financial inclusion come together with this deal.

Discover stockholders will get 1.0192 Capital One shares for every Discover share under the terms of the agreement. This is a 26.6% premium based on Discover's closing price of $110.49 on February 16, 2024. Upon closure, shareholders of Capital One will retain roughly 60% of the merged business, while shareholders of Discover would hold roughly 40%.

"We set out to create a payments and banking organization enabled by modern technology from the beginning when Capital One was founded. Richard Fairbank, the founder, chairman, and CEO of Capital One, stated, "Our acquisition of Discover is a unique opportunity to bring together two very successful companies with complementary capabilities and franchises, and to build a payments network that can compete with the largest payments networks and payments companies." "Through this combination, we're creating a company that is exceptionally well-positioned to create significant value for consumers, small businesses, merchants, and shareholders as technology continues to transform the payments and banking marketplace."

"The transaction with Capital One brings together two strong brands with enhanced ability to accelerate growth and maximizes value for our shareholders, enabling them to participate in the tremendous upside of the combined company," said Michael Rhodes, president and CEO of Discover. "This deal demonstrates the resilience of our company and the diligence of Discover staff members. As a member of the Capital One family, we're excited about the future and about giving our devoted clients more opportunities."

More Information : https://bit.ly/3OScvgt
Why API testing is important
Tags: javascript, beginners, programming, tutorial
Published: 2024-02-21 10:11:14

Test pyramids are a fundamental notion in [automation tools to test API](https://www.fireflink.com/api-automation-testing). It explains how to approach automated testing for a project: which portions to test first, as they form the base of the pyramid, and which to leave for the last phases, as the pyramid tip.

The first tier, following the testing pyramid paradigm, is the unit test layer, which is commonly conducted by developers as they are developing code. The server layer is where API testing occurs. UI testing occurs after the front end has been completed.

Visit Website: [Automation Tools To Test API
](https://www.fireflink.com/api-automation-testing)