リンクを新しいタブで開く
  1. A Promise in JavaScript is an object that represents the eventual completion (or failure) of an asynchronous operation and its resulting value. It allows you to associate handlers with an asynchronous action's eventual success value or failure reason. This lets asynchronous methods return values like synchronous methods: instead of immediately returning the final value, the asynchronous method returns a promise to supply the value at some point in the future.

    Creating a Promise

    To create a promise, you use the Promise constructor, which takes an executor function with two arguments: resolve and reject. These arguments are callbacks provided by JavaScript itself. The resolve function is called when the asynchronous operation is successful, and the reject function is called when it fails.

    let myPromise = new Promise((resolve, reject) => {
    // Asynchronous operation
    setTimeout(() => {
    resolve("Success!"); // Operation successful
    }, 1000);
    });
    コピーしました。

    Using Promises

    Once a promise is created, you can use the then(), catch(), and finally() methods to handle the promise's eventual value or error.

  1. JavaScript Promises - W3Schools

    Learn how to use JavaScript Promises to handle asynchronous code with callbacks. See examples of how to create, resolve, reject and consume promises with timeout and fil…
    Javascript Promise Object

    A Promise contains both the producing code and calls to the consuming code: When the producing code obtains the result, it should call one of the two callbacks:

    Promise Object Properties

    A JavaScript Promise object can be: 1. Pending 2. Fulfilled 3. Rejected The Promise object supports two properties: state and result. While a Promise object is "pending" (working), the result is undefined. When a Promise object is "fulfilled", the re…

    Javascript Promise Examples

    To demonstrate the use of promises, we will use the callback examples from the previous chapter: 1. Waiting for a Timeout 2. Waiting for a File

    Browser Support

    ECMAScript 2015, also known as ES6, introduced the JavaScript Promise object. The following table defines the first browser version with full support for Promise objects:

  2. Promise - JavaScript | MDN - MDN Web Docs

    2026年1月21日 · In this example, the promise chain is initiated by a custom-written new Promise() construct; but in actual practice, promise chains more typically start with an API function (written by …

  3. JavaScript Promise - GeeksforGeeks

    2026年1月17日 · JavaScript Promises make handling asynchronous operations like API calls, file loading, or time delays easier. Think of a Promise as a placeholder …

    欠落単語:
    • Example
    次が必須:
  4. Promise - The Modern JavaScript Tutorial

    2024年12月11日 · Learn how to create and use promises, special JavaScript objects that link producing and consuming code. See examples of promise …

  5. JavaScript Promises for Beginners - freeCodeCamp.org

    2022年5月25日 · In JavaScript, a promise is a placeholder (proxy) for the value of an ongoing operation. You typically use a promise to manage situations where …

  6. JavaScript Promises: From Beginner to Expert - DEV …

    2023年9月8日 · Promises are a powerful tool in JavaScript that help manage asynchronous operations and provide a more readable and maintainable …

  7. JavaScript Promises

    In this tutorial, you will learn about JavaScript promises and how to use them effectively in asynchronous programming.

  8. JavaScript Promise with Examples - Dot Net Tutorials

    In the next article, I am going to discuss JavaScript Promise Chaining with Examples. Here, in this article, I try to explain the JavaScript Promise with …

  9. JavaScript Promise and Promise Chaining - Programiz

    Learn how to use promises to handle asynchronous operations in JavaScript. See examples of creating, chaining, and using methods such as then(), catch(), and …

  10. JavaScript Promises Cheatsheet - Complete Guide | Developer Updates

    Learn how to handle asynchronous operations in JavaScript with easy-to-understand examples. Perfect for beginners and intermediate developers looking to master Promises and async/await.

  11. 他の人も質問しています
    読み込んでいます
    回答を読み込めません