Перейти до основного вмісту
← ⚡ JavaScript & the browser·Модуль C7 · Урок 8
ЗавданняUse console.time('compute') + console.timeEnd('compute') around a small loop (sum 1..1000). Then console.warn('careful') and console.error('boom'). Finally console.table([{a:1,b:2},{a:3,b:4}]).

console beyond .log — group, table, time, trace

100 XP7 min
Теорія

You're using 1/5 of console

console.log is the workhorse but the other methods solve real debugging problems.

console.table

Renders an array of objects as a real table. Sortable in devtools.

const users = [{ id: 1, name: "Anna" }, { id: 2, name: "Bob" }];
console.table(users);

console.group / groupEnd

Collapsible sections in devtools. Best for nested operations.

console.group("loadDashboard");
console.log("step 1");
console.log("step 2");
console.groupEnd();

console.time / timeEnd

Measures elapsed time. Pair with the same label.

console.time("parse");
const data = JSON.parse(huge);
console.timeEnd("parse"); // parse: 4.3ms

console.trace

Logs a stack trace from the current call site. Find "who called this".

console.warn / error

Same as log but devtools colors them yellow/red. Filter by level.

🔒

Зареєструйся щоб кодувати

Теорія відкрита всім. Інтерактивний редактор, живий перегляд і перевірка відкриваються з 7-денним безкоштовним trial — потрібна картка, скасування у будь-який час.

Реєстрація — безкоштовний trial →

Перші 10 уроків у кожному треку — безкоштовні. Картка не потрібна.

← НазадНаступний урок →

Отримуй одну пораду з Python чи вебу — щодня поштою

Коротко, без води, без спаму. Відписка — в один клік.