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

317
Views
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 answers
Answer question

0

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

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!