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

174
Views
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 answers
Answer question

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 Report

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 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!