Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

264
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda