const mustStay = arr => arr.every(n => n.value !== '-');
const newArr = arr.filter(mustStay);
// или
const newArr = [];
for (const n of arr) {
if (mustStay(n)) {
newArr.push(n);
}
}
// или
const newArr = [];
for (let i = 0; i < arr.length; i++) {
if (mustStay(arr[i])) {
newArr[newArr.length] = arr[i];
}
}
// или
const newArr = (function get(i, n = arr[i]) {
return n
? [ mustStay(n) ? [ n ] : [], get(i + 1) ].flat()
: [];
})(0)
for (let i = 0; i < arr.length; i++) {
if (!mustStay(arr[i])) {
for (let j = i--; ++j < arr.length; arr[j - 1] = arr[j]) ;
arr.pop();
}
}
// или
arr.reduceRight((_, n, i, a) => mustStay(n) || a.splice(i, 1), null);
// или
arr.splice(0, arr.length, ...arr.filter(mustStay));
// или
arr.length -= arr.reduce((acc, n, i, a) => (
a[i - acc] = n,
acc + !mustStay(n)
), 0);
filter({ name } => ...);
filter(/* передать объект как аргумент можно */{ name: name } /* а дальнейшее не валидно -> */ => ...)
$("#navigation_slider").stop().animate(...)
<body>
<section class="video-block">
<div class="information">
<select id="select">
<option disabled selected>Выберите язык</option>
<option>Английский язык</option>
</select>
<a data-text="Video information:">Информация о видео:</a>
<a data-text="Title: All For The Sake Of Hype">Название: Всё Ради Хайпа</a>
<a data-text="№1 in YouTube trends">№1 в трендах YouTube</a>
<a data-text="Number of views: 1.5 million">Количество просмотров: 1.5млн</a>
<a data-text="Number of likes: 10 chiliad">Количество лайков: 10тыч</a>
</div>
<figure>
<video id="mesto" class="vidos nety" controls="controls" copreload="auto" autoplay="true" loop="true" muted="muted">
<source src="src/video.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
</video>
</figure>
</section>
<section class="button-block">
<div id="button" class="button">
<a id="buttonText" data-text="Watch video" href="#">Смотреть видео</a>
</div>
</section>
<script src="js/script.js"></script>
</body>
window.onload = function() {
let a = document.getElementById('button');
let vidos = document.getElementById('mesto');
let b = document.getElementById('select').options.selectedIndex;
let texts = document.querySelectorAll('[data-text]');
let textButton = document.getElementById('buttonText');
let video = function() {
vidos.classList.remove("nety");
if (b == 0) {
texts.forEach(el => el.textContent = el.dataset.text);
textButton.textContent = textButton.dataset.text;
};
};
a.onclick = video;
}
var knopka = document.getElementById ('push');
knopka.addEventListener('click',func1);
function func1() {
var shadow = document.getElementById ('ts1');
if (shadow.style.display !== 'none'){
shadow.style.display="none";
}else{
shadow.style.display="block";
}
};
click()
– есть метод с таким же названием у document.body
. Попробуйте написать для какой-нибудь кнопки onclick="console.log(document.body.click === click);"
true
.click()
как-то иначе, и пропишите ее новое название везде в onclick
. Вот ваш код, где заменили только имя функции с click на myclick, работает:onclick
– дурной тон нынче. (Если только вы не Vue.js : )let arrayFirst = [2, 5, 8, 1];
let arraySecond = [
{id: 34, name: 'test'},
{id: 5, name : 'test1'},
{id: 123, name: 'test2'}
];
// Если нужны все
const all = arraySecond.filter((y) => arrayFirst.includes(y.id));
// Если только первое совпадение
const first = arraySecond.find((y) => arrayFirst.includes(y.id)));
let func = alertFinished.bind(null, 'ваш аргумент') // тут null это контекст this, но он нам не нужен. Нам нужен второй аргумент
doHomework('math', func);
doHomework('math', function () { alertFinished('ваш аргумент') });
@media screen and (max-width: 1200px) {
.content {
font-size: 50px;
}
}
@media screen and (max-width: 1000px) {
.content {
font-size: 44px;
}
}