Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

263
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda