-
i dont seem to understand why, when i'm defining variables, sometimes i need to pus curly braces, like right here: can somebody tell me why please? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
Hi @h0leee ,
Similarly, This is called object destructuring. Hope that explanation wasn't too messy. |
Beta Was this translation helpful? Give feedback.
Hi @h0leee ,
await ethers.getContract("FundMe", deployer)
returns a javascript object (something like this{"property1":"value1", "property2":value2}
).We're therefore storing that whole object in the constant fundMe with
const fundMe
.Similarly,
await getNamedAccounts()
returns a javascript object that looks like{"user":userAddress, "deployer":deployerAddress, ...}
. However, we are not interested in storing the whole object this time. All we want is a single account, the deployer.So what this syntax
const { deployer }
does is store the value of the property named deployer in a variable called deployer. This means that now, deployer = deployerAddress. We could also doconst {user} = awa…