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

261
Views
Adding namespace in JavaScript cause Unexpected token '.' error

I follow the instructions in https://stackoverflow.com/a/881556/2704265 to add a namespace, as below:

var theme1 = {
    document.addEventListener('DOMContentLoaded', function() {
    });
};

However, after that, I will get Uncaught SyntaxError: Unexpected token '.' which point to the '.' after 'document', why?

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

0

Taking a look at the example given in the answer provided you have the following:

var yourNamespace = {

    foo: function() {
    },

    bar: function() {
    }
};

...

yourNamespace.foo();

The code you gave would need to look something more like this:

var themeNamespace = {
   domLoader: function() {
      document.addEventListener('DOMContentLoaded', function() {
    });
   },
}

Then run using themeNamespace.domLoader();

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!