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

167
Views
how to pass ejs variable to extern js script

i have a script on my html page like that:

<script>
    let a = <%-JSON.stringify(tags)%>
</script>

now I need this variable on my main.js file. But I don't know how I can access it

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

0

You can access it with window.a, as long as that script tag is above the script tag for main.js, but this requires a different way to set the value at the start.

<script>
  window.a = <%-JSON.stringify(tags)%>;
</script>

access in your code like

let foo = a.bar;
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!