const regex = /\d+/g;const str = 'abc123def456';console.log(regex.test(str), regex.test(str));
const user = { name: 'Alice' };const { name, age = 25, city = 'NY' } = user;console.log(age, city);
.list li:first-of-type { color: red;}.list li:last-of-type { color: blue;}
const numbers = [5, 10, 15, 20];const index = numbers.findLastIndex(n => n > 12);console.log(index, numbers[index]);
const arr = [1, NaN, 3];const found1 = arr.includes(NaN);const found2 = arr.indexOf(NaN);console.log(found1, found2);
.card::before { content: '★'; position: absolute; top: 10px; left: 10px;}
const items = document.querySelectorAll('.item');const isArray = Array.isArray(items);const canMap = typeof items.map === 'function';console.log(isArray, canMap);
const btn = document.querySelector('.btn');btn.dataset.id = '123';btn.dataset.userName = 'Alice';console.log(btn.getAttribute('data-user-name'));
.container { display: flex; align-content: space-between; flex-wrap: wrap; height: 300px;}
const str = 'JavaScript';const char1 = str[0];const char2 = str.charAt(0);str[0] = 'j';console.log(str[0], char1 === char2);