Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

272
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda