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

194
Views
Using Object.keys() to get searchParams

Considering the below:

const [searchParams, setSearchParams] = useSearchParams();

  console.log(searchParams.toString());

  console.log(typeof searchParams);

  console.log(Object.values(searchParams));

And passing the URL http://localhost:3000/client-data?task=test

This logs:

task=test (The string of the object, understandable)

object (We know it's of type object, and has some key value pairs from prior test)

[] (Why are we not getting any keys / values from Object.keys() etc?)

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

0

Why are we not getting any keys / values from Object.keys() etc?

The key/values of the search params are not exposed as own properties of the object instance. They cannot be. Consider the following

const params = new URLSearchParams("a=1&get=2");

console.log(params.a);
console.log(params.get);

console.log(params.get("a"));
console.log(params.get("get"));

If params.a gave you the value "1", then params.get should also give you "2". Yet that means it would overwrite the .get() method. And if that were to happen, then params.get("a") would never work.

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!