$headers = array_column($data[0]['pages'], 'name');
$columns = array_column($data[0]['pages'], 'attribute');
$rowCount = max(array_map('count', $columns));
$headersHTML = implode('', array_map(function($n) {
return "<th>$n</th>";
}, $headers));
$rowsHTML = implode('', array_map(function($i) use($columns) {
return "
<tr>".implode('', array_map(function($n) use($i) {
return "<td>".($n[$i] ?? '')."</td>";
}, $columns))."
</tr>";
}, range(0, $rowCount - 1)));
echo "
<table>
<thead>
<tr>$headersHTML</tr>
</thead>
<tbody>$rowsHTML</tbody>
</table>";
fetch('https://api.novaposhta.ua/v2.0/json/', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
modelName: 'Address',
calledMethod: 'getWarehouses',
methodProperties: {
CityName: document.querySelector('.myCityName').textContent,
},
apiKey: '',
}),
})
.then(r => r.json())
.then(r => {
document.querySelector('.mySelect').innerHTML = r.data
.map(n => `<option>${n.Description}</option>`)
.join('');
});
setInterval(tesla.moveRight,30)setInterval(tesla.moveRight.bind(tesla), 30)setInterval(() => tesla.moveRight(), 30)class Car {
...
moveRight = () => {
...
}
}
Библиотеки и фреймворки (React, Vue, Redux...) даются очень тяжело.
Нравится работать с чистым js
используется для получения и установки инлайновых стилей
когда нажимаю повторно чтобы остановить музыку, она не останавливается
const result = arr
.reduce((acc, n, i, a) => (
a[i - 1] !== n && acc.push([ n, 0 ]),
acc[acc.length - 1][1]++,
acc
), [])
.map(([ v, c ]) => c < 2 ? v : Array(c).fill(v));const result = arr
.reduce((acc, n, i, a) => (
a[i - 1] === n || acc.push([]),
acc[acc.length - 1].push(n),
acc
), [])
.map(n => n.length === 1 ? n[0] : n);const result = arr.reduce((acc, n, i, a) => {
const prev = n === a[~-i];
const next = n === a[-~i];
!prev && next && acc.push([]);
(prev || next ? acc[~-acc.length] : acc).push(n);
return acc;
}, []);
const length = 48;
const step = 30;
const locale = 'en-US';
const options = {
hour: '2-digit',
minute: '2-digit',
};const times = Array.from({ length }, (_, i) => {
return new Date(0, 0, 0, 0, step * i).toLocaleTimeString(locale, options);
});
// или
const times = Array.from({ length }, function() {
return this[1].format(this[0].setMinutes(this[0].getMinutes() + step));
}, [ new Date(0, 0, 0, 0, -step), new Intl.DateTimeFormat(locale, options) ]);
u:preg_match_all("/[а-я]{4,}/ui", $string, $keywords);
использую известный компонент vue-select он довольно удобный но у него нет того что мне нужно, а именно отображения опций в виде html-кода а не текста