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

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

0

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

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