Storage.deployed())"在 JavaScript 中实际上意味着什么?-6ren"> Storage.deployed())"在 JavaScript 中实际上意味着什么?-这个问题已经有答案了: What does "=>" mean in JavaScript? [duplicate] (1 个回答) When should I use arrow functions-6ren">
gpt4 book ai didi

javascript - ".then(() => Storage.deployed())"在 JavaScript 中实际上意味着什么?

转载 作者:行者123 更新时间:2023-12-03 00:05:46 25 4
gpt4 key购买 nike

我正在学习 Solidity,部署脚本是这样的,

var Storage = artifacts.require("./Storage.sol");
var InfoManager = artifacts.require("./InfoManager.sol");

module.exports = function(deployer) {

// Deploy the Storage contract
deployer.deploy(Storage)
// Wait until the storage contract is deployed
.then(() => Storage.deployed())
// Deploy the InfoManager contract, while passing the address of the
// Storage contract
.then(() => deployer.deploy(InfoManager, Storage.address));
}

我似乎无法在 Google 上搜索右箭头字符“=>”。

最佳答案

() => 是 Javascript 中的箭头函数。

定义

An arrow function expression is a syntactically compact alternative to a regular function expression, although without its own bindings to the this, arguments, super, or new.target keywords. Arrow function expressions are ill suited as methods, and they cannot be used as constructors.

Read more about arrow functions

.then()

定义:

The then() method returns a Promise. It takes up to two arguments: callback functions for the success and failure cases of the Promise.

Read more about Promise.prototype.then()

发生的情况是,当 deployer.deploy(Storage) promise 已解决时,您将执行函数 storage.deployed() 作为回调函数。

关于javascript - ".then(() => Storage.deployed())"在 JavaScript 中实际上意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54968654/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com