JavaScript Console API (log, error, table) Quiz
Explore 40 questions that cover console.log, console.error, console.table, message formatting, styling, grouping, timing, assertions, debugging workflows, clearing output, and practical logging best practices in JavaScript.
Question 1
What is the console API primarily used for?
Question 2
Which statement describes console.log?
Question 3
Which placeholder inserts a string when using console.log formatting?
Question 4
Which console method reports error-level logs with stack traces in most browsers?
Question 5
What does this snippet produce?
const users = [
{ id: 1, name: 'Ana' },
{ id: 2, name: 'Raj' }
]
console.table(users)Question 6
Which placeholder highlights numbers in console.log?
Question 7
How can you style console output with CSS?
Question 8
Which technique helps highlight variable names next to their values?
const total = 42
console.log({ total })Question 9
What is a benefit of logging template literals?
Question 10
Which practice keeps console output organized?
Question 11
Which method prints an object with its properties expanded immediately?
const user = { id: 7, name: 'Mina', meta: { active: true } }
console.dir(user)Question 12
What is the advantage of logging a Map with console.table?
Question 13
Which method counts how many times a label has been logged?
Question 14
What output results from this code?
const foo = 'A'
const bar = 3
console.log({ foo, bar })Question 15
Why should sensitive data be filtered before logging objects?
Question 16
What does the following produce?
console.log('%cWarning', 'color: orange; font-weight: bold')Question 17
What is printed here?
console.group('Auth')
console.log('Login start')
console.groupEnd()Question 18
Given the code, what is displayed?
console.groupCollapsed('Data')
console.log('Fetch users')
console.log('Fetch posts')
console.groupEnd()Question 19
What happens if console.groupEnd is called without a matching console.group?
Question 20
Which scenario benefits from console.group?
Question 21
What is output here?
console.time('fetch')
// ... async work
console.timeEnd('fetch')Question 22
What happens if console.timeEnd is called with a label that was never started?
Question 23
What does the following assert do?
console.assert(Array.isArray(users), 'Users must be an array')Question 24
Why use console.time when profiling specific blocks?
console.time('task')
expensiveWork()
console.timeEnd('task')Question 25
What is a drawback of leaving console.time in production code?
Question 26
What does this snippet produce?
try {
throw new Error('Failed to save')
} catch (err) {
console.error('Save error:', err)
}Question 27
When should console.error be preferred over console.log?
Question 28
How can console.table support debugging API responses?
Question 29
Why is console.log often replaced with debugger statements during deep investigation?
Question 30
What is a common best practice after finishing debugging?
Question 31
What happens when running this snippet?
console.log('A')
console.clear()
console.log('B')Question 32
What is the result of console.count("api") repeated three times?
Question 33
What does console.countReset("api") do?
Question 34
Which method outputs a warning with stack trace but lower severity than console.error?
Question 35
What does console.trace do?
Question 36
Why avoid leaving verbose console.log statements in production?
Question 37
Which approach makes console logging configurable?
Question 38
How can console.assert improve defensive programming?
Question 39
What is a best practice when combining console.log with objects?
Question 40
Which guideline keeps console usage sustainable?
