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

179
Visualizações
Can colon (:) be used for assignment in JavaScript?

I'm new in JavaScript. I was programming and I saw some used

const PI : 3.14

I'm puzzled how ':' notion can be used to assign values to variables. Can anyone explain to me when ':' is used to assign values to variables? That'll be really helpful ^^

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

If you are just assigning a variable, you can't use a colon. What you want is const PI = 3.14. Colons can be used for other purposes however, for example, setting keys in an object:

const myObject = {
    key: "my new value"
}
about 4 years ago · Juan Pablo Isaza Relatório

0

NO! That is the wrong syntax and will throw error in JS.

Either you write

const PI = 3.14;

OR

const Obj1 = {PI: 3.14}

These, are the valid syntax in JS.

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