javascript – 承诺的重新定义

前端之家收集整理的这篇文章主要介绍了javascript – 承诺的重新定义前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Promise现在是es6中的全局保留字,而linters则抛出错误.那么这样做的缺陷是什么呢?
var Promise = require("bluebird");

或者我应该这样做

var BluebirdPromise = require("bluebird");

解决方法

看起来重新宣布承诺没有问题,只要它不是全球性的.但第二个是更好的方法

Many of us do that. There’s no problem. You’re just using a faster implementation,that’s all. But note that you may use more and more promises given by varIoUs libraries,so this is a very limited replacement (there are discussions in the node world about ways to define a library as a global promise provider). – Denys Séguret

原文链接:https://www.f2er.com/js/156807.html

猜你在找的JavaScript相关文章