์ฝ์์ฐฝ์ ๊ฐ์ข ์ฐ์ฐ ๋ฐ ํจ๊ณผ๋ฅผ ๋ฃ๋ ๋ฐฉ๋ฒ๋ค
์ด๊ธฐ์ฝ๋
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>Console Tricks!</title>
</head>
<body>
<p onClick="makeGreen()">รBREAKรDOWNร</p>
<script>
const dogs = [{ name: 'Snickers', age: 2 }, { name: 'hugo', age: 8 }];
function makeGreen() {
const p = document.querySelector('p');
p.style.color = '#BADA55';
p.style.fontSize = '50px';
}
// Regular
// Interpolated
// Styled
// warning!
// Error :|
// Info
// Testing
// clearing
// Viewing DOM Elements
// Grouping together
// counting
// timing
</script>
</body>
</html>
// Regular
console.log('Hello');
// Interpolated
let value= '๐ฉ';
console.log('Hello I am a %s String!!', '๐ฉ');
console.log(`Hello I am a ${value}`);
// Styled
// %c ๋ style์ ๋จน์ผ์ ์๋ค.
console.log('%c I am some great text', 'font-size:50px; background:red; text-shadow: 10px 10px 0 blue');
// warning!
console.warn('Oh No!!');
// Error :|
console.error('Oh No!!');
// Info
console.info('Crocodiles eat 3-4 people per year');
// Testing
// ํ๋ฆฌ๋ฉด ์ถ๋ ฅ๋๊ณ ์๋๋ฉด ์ถ๋ ฅ์๋จ.
const p = document.querySelector('p');
console.assert(p.classList.contains('ouch'), 'That is wrong!');
// clearing
console.clear();
// Viewing DOM Elements
console.log(p);
console.dir(p);
// Grouping together
dogs.forEach(dog => {
console.groupCollapsed(`${dog.name}`);
console.log(`This is ${dog.name}`);
console.log(`${dog.name} is ${dog.age} years old`);
console.log(`${dog.name} is ${dog.age * 7} dog years old`);
console.groupEnd(`${dog.name}`);
});
// counting
console.count('Wes');
console.count('Wes');
console.count('Steve');
console.count('Wes');
console.count('Steve');
console.count('Steve');
console.count('Wes');
console.count('Steve');
console.count('Steve');
console.count('Steve');
// timing
console.time('fetching data');
fetch('https://api.github.com/users/wesbos')
.then(data => data.json())
.then(data => {
console.timeEnd('fetching data');
console.log(data);
})
console.table(dogs);