DEV Community

Discussion on: All front end Interview questions asked during my recent job hunt.

Collapse
constantiner profile image
Konstantin Kovalev

2) Create a promise from scratch

Sorry, but your promise implementation is wrong. then and catch must return new Promise instance but not this. That's why your sample doesn't work correct:

promise
  .then(function(response){
    console.log(response);
  return [...response];
  }).
then(response => {
  console.log(response);
})
  .catch(function(error){
    console.log(error)
  });

Compare results using original Promise.