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

259
Views
Why do these function arguments have colon characters?

Can someone please explain these parameters to this function in react to me.

enter image description here

I have never seen functions parameters with a :. What exactly is it? ConditionalFormattingConfig is a defined type.

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

0

You are looking at TypeScript. There is 1 parameter, which is an Object. That's the 1st {}. Then there is a colon and another object... but that stuff after the colon is not another key:value object it is the definition of the 1st object. It's saying the 1st object must have a "config" key and the value of the config key is a "ConditionalFormattingConfig" whatever that is. And it must have an "onChange" key that takes a function that accepts a 'config' parameter (of type ConditionalFormattingConfig) and returns nothing (void). Etc....

And back to the 1st parameter, instead of using a variable name for the parameter this function takes, it is using something called "object destructuring". So instead of asking for a variable called params and then accessing it as "params.config", they are pulling the keys out of the object into variables.

// You can do this
function doSomething(params) {
  doSomethingWith(params.config)
}

// This is the same with object destructuring
function doSomething({config}) {
  doSomethingWith(config)
}

const myObject = {config: 'fast'}
doSomething(myObject)

Hope that clears things up.

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!