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

318
Visualizações
console.clear() not working after puting a self-invoking function

I'm currently doing the 30 day JavaScript course by Asabeneh here in github. After fiddling around with the codes, there is this weird error if I put a self-invoking function after console.clear().

I have a list of country objects loaded:

const countries = [
  {
    name: 'Afghanistan',
    capital: 'Kabul',
    languages: ['Pashto', 'Uzbek', 'Turkmen'],
    population: 27657145,
    flag: 'https://restcountries.eu/data/afg.svg',
    currency: 'Afghan afghani'
  },
  {
    name: 'Åland Islands',
    capital: 'Mariehamn',
    languages: ['Swedish'],
    population: 28875,
    flag: 'https://restcountries.eu/data/ala.svg',
    currency: 'Euro'
  },...
]

These are the code I wanted to execute:

console.time('for of loop')
for(const country of countries){
    console.log(country.name, country.capital)
}
console.timeEnd('for of loop')

console.clear()

// Level 1.
(function () {
    console.table(countries)
})()

The error shows main.js:23 Uncaught TypeError: console.clear(...) is not a function at main.js:23:1.

if I remove the self-invoking code. The code works just fine.

Console was cleared

I just don't understand what is going on here.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

put a semicolon (;) after console.log(…);

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