const div = document.createElement('div');
[
['text', 'name', 'Введите имя'],
['text', 'phone', 'Введите номер телефона'],
['email', 'email', 'Введите адрес электронной почты'],
].forEach((d) => {
const input = document.createElement('input');
[input.type, input.name, input.placeholder] = d;
div.appendChild(e);
}
// ...
document.body.appendChild(div);
document.querySelector('#abc').innerText
// Uncaught TypeError: document.querySelector(...) is null
const el = document.querySelector('#abc');
const text = el === null ? 'default Text' : el.innerText;
const text = document.querySelector('#abc')?.innerText ?? 'default Text';
const removeDuplicates = (arr) =>
arr.reduce(
(acc, cur) => (acc.includes(cur) ? acc : (acc.push(cur), acc)),
[],
);
console.log(removeDuplicates([1,2,3,4,5,1,1,2,2,3,3,65,9,65,1,5,65, 117, 117, 118,118, 12333, 12333]));
// Array(10) [ 1, 2, 3, 4, 5, 65, 9, 117, 118, 12333 ]