The following code use Destructuring
:
var obj = {
fun1:function() { console.log('Working') }
};
obj = { fun1:function(){ console.log("Replaced Working")} }
obj.fun1();
//output:
//Replaced Working
Does the following Promise
do the same?
var pr = Promise.resolve({then:function(resolve){
resolve(20);
}
})
pr.then(function(v){
console.log(v);
})
that's mean,pr
is equal Promise
object that,its then
method changed to:
function(resolve){
resolve(20);
}
and finally,pr.then(function(v){...}
produces result.if don't use of Destructuring
,so why there is passed then
property in Promise.resolve
?