Tag:promise

  • Summary of several extension APIs of promise

    Time:2019-12-12

    Summary of several extension APIs of promise 1. Promise.none Description: In contrast to promise.all, when all promises are rejected, the none method executes the completed resolution. If there is a promise executed the completed resolution, the none method executes the rejection code: Promise.none = function(promises) { return Promise.all(promises.map(promise => { return new Promise((resolve, reject) => […]

  • Understanding callback and promise

    Time:2019-12-11

    Understanding callbacks and promise Original from engineer Fernando Hernandez blog, portal These two concepts are the basic contents of JavaScript programming language. Because this language works under the paradigm of asynchronous programming. So, I decided to share this article to understand the two features used to perform asynchronous operations — callback and promise. So let’s […]

  • Write a promise that meets promise / A + specifications

    Time:2019-12-10

    Write a promise that meets promise / A + specifications Long warning! It’s a little long. You can watch it selectively. If you are not clear about the promise source code, you are recommended to look from the beginning. I believe that you can see from the beginning to the end carefully, and you can […]

  • Ajax fetch and Axios (continuously updated…)

    Time:2019-12-9

    Ajax fetch and Axios (continuously updated…) Sorting out knowledge points AJAX is not the specification of JavaScript, it is just an abbreviation of “invention” of a friend: asynchronous JavaScript and XML, which means to execute asynchronous network requests with JavaScript. Javascript code is executed by single thread. Due to this “defect”, all network operations and […]

  • You may only differ from understanding promise in this article (2)

    Time:2019-12-7

    Let me see~ There may be some inaccuracies in the explanation. Please correct Promise has been active in the JavaScript community in long time ago and is popular with developers. It was only in recent years that promise was included in the ECMA specification. Why do we use promsie? Because: We don’t want the code […]

  • Loading pictures in sequence

    Time:2019-12-6

    Normal picture loading //Normal picture loading var imglist = [‘https://imgs.developpaper.com/imgs/2.png’,’https://avatars3.githubusercontent.com/u/34082804?s=460&v=4′,’https://github.githubassets.com/images/search-key-slash.svg’,’./img/2.jpg’,’https://avatars3.githubusercontent.com/u/34082804?s=460&v=4′]; loadImg(imglist); function loadImg(imglist){ var imgarr = []; var curimg = 0; var body = document.getElementsByTagName(‘body’); for(var i =0;i<imglist.length;i++){ var img = new Image(); img.src = imglist[i]; img.style.width = ‘200px’; img.id = i; img.onload = function(){ console.log(‘show ‘+this.id) } imgarr.push(img); body[0].appendChild(img); } } Sequence loading picture […]

  • Implement a promise by yourself

    Time:2019-12-5

    Promise basic usage The promise object is a proxy object, and the value of the proxy may be unknown when the promise object is created. It allows you to bind handlers for the success and failure of asynchronous operations. This allows asynchronous methods to return values as synchronous methods do, but not immediately return the […]

  • Source code implementation of promise (perfect in accordance with promise / A + specification)

    Time:2019-12-4

    Promise is a high-frequency question in the front-end interview. When I was an interviewer, the probability of asking promise was more than 90%. As far as I know, most companies would ask some questions about promise. If you can write the source code that conforms to the specifications of promise a +, I think you […]

  • Traffic light effect

    Time:2019-12-3

    This implementation comes from section 16 JavaScript execution in winter’s “relearn the front end” (1): why does the code in promise execute before setTimeout?In the last question, use to achieve a traffic light effect. <body> <style> .redgreenlight{ width: 100px; height: 100px; margin: 0 auto; border-radius: 50%; line-height: 100px; text-align: center; background-color: #eee; border: double 3px […]

  • Promise / A + standard translation and handwritten implementation

    Time:2019-12-2

    If you want to implement promise by hand, first look at the promise / A + specification, then implement it, and you will get twice the result with half the effort.Let me translate the content of promise / A + specification first. term1.1 promise is an object or function with a then method that conforms […]

  • 30 minutes, let you fully understand promise principle

    Time:2019-12-2

    Preface It was recorded a while agopromiseIn this article, we will go a step further to analyzepromiseHow is this rule mechanism implemented. PS: This article is suitable for people who have already known about the usage of promise. If you don’t know much about its usage, you can move to my last blog post. This […]

  • Analysis of ES6 promise source code

    Time:2019-11-30

    Main logic: In essence, it’s the callback function.The distinction between asynchronous and synchronous is completed through the judgment of “subscribers”.Through resolve, reject – > publish – > invokecallback – > resolve, the recursion of reject and the next parent of then is the previous child to complete the flow of then chain Function flow under […]