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

106
Views
Why JavaScript return True for following condition?

While solving one issue, I notice following condition

if("String" == ["String"]) {
    console.log("Valid");
}
else
{
    console.log("Invalid");

}

I thought that it should log "Invalid", since first value is string and second value is object of string. But to my surprise, it is logging "Valid". Any specific reason, why this condition is true.

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

0

You're using == to compare them, so the array is first converted to a string.

If you use === (which you probably should do always), they'll not be equal.

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!