Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
Assigning objects to { } in Javascript and Hardhat

Consider the following code snippet:

let { networkConfig, getNetworkIdFromName } = require('../helper-hardhat-config')
const fs = require('fs')

module.exports = async ({
    getNamedAccounts,
    deployments,
    getChainId
}) => {
const { deploy, get, log } = deployments
const { deployer } = await getNamedAccounts()
const chainId = await getChainId()
let linkTokenAddress
let vrfCoordinatorAddress

if (chainId == 31337) {
    let linkToken = await get('LinkToken')
    let VRFCoordinatorMock = await get('VRFCoordinatorMock')
    linkTokenAddress = linkToken.address
    vrfCoordinatorAddress = VRFCoordinatorMock.address
    additionalMessage = " --linkaddress " + linkTokenAddress

    ...........
    ...........

In Javascript, I understand how objects are assigned to variables. eg x = {one: 1, two: 2 } but I don't understand how const { deploy, get, log } = deployments in the above code works. Just to experiment with, on the console I entered the following lines {var1,var2}={one: 1, two: 2 } but the variable var1 and var2 came as Undefined. I am just trying to understand how it is possible, for example, to use the get property as a function as in let linkToken = await get('LinkToken')

Thanks in advance !

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It's called object destructuring, check about it here https://www.freecodecamp.org/news/javascript-object-destructuring-spread-operator-rest-parameter/

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!