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

144
Views
Next.js localstorage value always return false

I'm trying to check is localStorage value is correct. Localstorage value is successfully saved. I wonder why it always return false.

console.log('isTrue',localStorage.getItem('third') == "2") // false
console.log('value',localStorage.getItem('third'))  // "2"
localStorage.setItem('third', JSON.stringify(third)) // save like this

enter image description here

enter image description here

Can someone help what is wrong? Thanks!

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

0

Check the API spec for local storage and the get/set methods, particularly the return type of .getItem - you'll need to JSON.parse the store value before doing comparisons between other data or doing other work with it, i.e.

console.log('isTrue', JSON.parse(localStorage.getItem('third')) === "2") --> true
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!