Array.from([...str].reduce((acc, n) => acc.set(n, -~acc.get(n)), new Map), n => n[1] + n[0])str.split('').sort().join('').match(/(.)\1*/g).map(n => n.length + n[0])Array.from(new Set(str), n => str.replace(RegExp(`[^${n}]`, 'g'), '').length + n)
const getLastDeepestElement = function(el) {
return this(el, 0)[0];
}.bind(function get(el, level) {
return [...el.children].reduce((p, c) => (
c = get(c, -~level),
p[1] > c[1] ? p : c
), [ el, level ]);
});function getLastDeepestElement(el) {
let result = [ el, 0 ];
for (const stack = [ result ]; stack.length;) {
const n = stack.pop();
result = n[1] > result[1] ? n : result;
stack.push(...Array.from(n[0].children, m => [ m, n[1] + 1 ]));
}
return result[0];
}const getDeepestLastElement = el =>
el.lastElementChild
? getDeepestLastElement(el.lastElementChild)
: el;const getDeepestLastElement = el => Array
.from(el.querySelectorAll('*'))
.pop() || el;
// или
function getDeepestLastElement(el) {
for (let c; (c = el.children).length; el = c[~-c.length]) ;
return el;
}
firebase.auth().onAuthStateChanged(user => {
if (user) {
store.dispatch('loggedUser', user);
}
new Vue(...);
});
.on('click', function(e) {
e.stopPropagation();
<script type="text/x-template" id="tree-template"> {{ item }} </script>
li - вы же внутри ul пытаетесь их выводить:<script type="text/x-template" id="tree-template">
<li>{{ item }}</li>
</script><ul v-for="item in items" :key="item.id"> <tree-items :item="item" ></tree-items> </ul>
v-for внутрь списка (кстати, а какого чёрта в имени компонента элемента списка множественное число? почему items, а не item?):<ul>
<tree-items
v-for="item in items"
:key="item.id"
:item="item"
></tree-items>
</ul>props: { item: {
setItem: function (_item) { this.item = _item;
function isComposite($num) {
// нет, за вас я этого делать не буду, давайте как-нибудь сами...
// в конце концов, можно и нагуглить - это дело трёх секунд
}$newArr = array_filter($arr, 'isComposite');
const valuesShow = [ 2000, ещё какое-то значение, и ещё, и ещё, ... ];$('#sample_form_deliv').change(function({ target: { value } }) {
$('#sample_form_pay .input-label:eq(2)').toggle(valuesShow.includes(+value));
});
Array.prototype.reduce.call(
document.querySelector('table').rows,
(acc, n) => {
if (!n.classList.contains('no')) {
acc[acc.length - 1].info.push({
subtitle: n.cells[0].textContent,
cell: n.cells[1].textContent,
});
} else if (!n.querySelector('.no2')) {
acc.push({
title: n.querySelector('.car').textContent,
info: [],
});
}
return acc;
},
[]
)
<div ref="map">mounted() {
this.map = L.map(this.$refs.map).setView([ 55.75222, 37.61556 ], 13);
...
x.domain([
d3.min(data, d => new Date(d.date)).setMonth(-1),
d3.max(data, d => new Date(d.date)),
]);
<v-data-table @click:row="onClickRow">methods: {
onClickRow(item) {
console.log(item);
},
...
$(this).parents('.portfolio')function parents(el, selector) {
const p = [];
while ((el = el.parentNode) !== document && el) {
(!selector || el.matches(selector)) && p.push(el);
}
return p;
}
parents(this, '.portfolio')$(this).parent('.portfolio')this.parentNode.classList.contains('portfolio') ? this.parentNode : null$(this).children('.portfolio')[...this.children].filter(n => n.classList.contains('portfolio'))
// или
Array.prototype.filter.call(this.children, n => n.matches('.portfolio'))
// или
this.querySelectorAll(':scope > .portfolio')$(this).find('.portfolio')this.querySelectorAll('.portfolio')$(this).next('.portfolio')(el => el && el.matches('.portfolio') ? el : null)(this.nextElementSibling)
let tr = event.target;
for (; !tr.matches('tr'); tr = tr.parentNode) ;
// или
const tr = event.target.closest('tr');event.currentTarget.insertBefore(draggableElement, tr.nextElementSibling);
// или
tr.insertAdjacentElement('afterend', draggableElement);
// или
tr.after(draggableElement);
new Vue({
store: store,
...new Vue({
store: createStore(),
...