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

87
Views
Javascript filter over HTMLCollection

I want to get particular query params from all the js files which have been loaded by the browser. My query params reside in the js file named script.js(ex: https://abcd.com/script.js?code=123). In the browser console, I tried like this:

const scripts = document.getElementsByTagName("SCRIPT")
scripts.filter((script) => { return script.src.includes("script.js?code=")})

But this returns the error Uncaught TypeError: document.getElementsByTagName(...).filter is not a function. Please suggest the code changes or is there any better way to get the same?

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

0

Methods like getElementsByTagName do not return an array rather a list of node. Just wrap your queryselector with brackets and the spread operator to create an array from the nodelist.

const scripts = [...document.getElementsByTagName("SCRIPT")]
scripts.filter((script) => { return script.src.includes("script.js?code=")})

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!