text
у какого-то значения. Например:record.messages[0]['item_apply_id'].text
record.messages[1]['add_date'].text
for (let i = 0; i < record.messages.length; i++) {
for (let message in record.messages[i]) {
console.log(i, message, record.messages[i][message]);
}
}
0 "id" "2222"
0 "item_apply_id" "693575"
0 "text" "aaaaaa"
0 "uid" "283238"
0 "add_date" "2020-07-20 19:19:12"
text
каждого элемента, следует использовать такой цикл:for (let i = 0; i < record.messages.length; i++) {
console.log(record.messages[i].text);
}
const deleteHandler = function (array) {
const filtered = array.filter(entry => entry !== this);
array.length = 0;
array.push(...filtered);
};
const array = [
{
id: 1,
delete: deleteHandler,
},
{
id: 2,
delete: deleteHandler,
},
];
console.log(array); // [ { id: 1, delete: [Function: deleteHandler] }, { id: 2, delete: [Function: deleteHandler] } ]
const a = array[1];
a.delete(array);
console.log(array); // [ { id: 1, delete: [Function: deleteHandler] } ]
Map
, вместо такого поведения. <iframe>
).const getPage = async url => {
const request = new Request(url, {
method: 'GET',
headers: new Headers({ 'Content-Type': 'text/html; charset=utf-8' }),
});
const response = await fetch(request);
const text = await response.text();
const parser = new DOMParser();
const virtualDocument = parser.parseFromString(text, 'text/html');
return virtualDocument;
};
getPage('some.html').then(virtualDocument => {
document.querySelector('.result').append(...virtualDocument.body.children);
});
const server = done => {
browserSync.init({
server: {
baseDir: 'path to server root'
},
notify: false
});
done();
};
exports.server = server;
exports.default = series(server, parallel(css, allcss));
browserSync.stream()
с PHP сломается, и лучше использовать таску для этого, в которой будете вызывать browserSync.reload()
. $(document).ready(function () {
$('select').change(function () {
const id = $(this).val();
const target = $(`#${id}`);
if (target.length !== 0) {
$('html, body').animate({
scrollTop: target.offset().top
}, 250);
}
});
});
const select = document.querySelector('select');
select.addEventListener('change', event => {
const target = document.getElementById(event.target.value);
if (target !== null) {
target.scrollIntoView({
behavior: 'smooth'
});
}
});
const items = [
{
name: 'Apple',
dropChance: 0.7
},
{
name: 'Knife',
dropChance: 0.25
},
{
name: 'Spoon',
dropChance: 0.25
},
{
name: 'Ice Cream',
dropChance: 0.1
}
];
const lerp = (min, max, value) => ((1 - value) * min + value * max);
const drop = items => {
const total = items.reduce((accumulator, item) => (accumulator + item.dropChance), 0);
const chance = lerp(0, total, Math.random());
let current = 0;
for (const item of items) {
if (current <= chance && chance < current + item.dropChance) {
return item;
}
current += item.dropChance;
}
};