В консоле выдает Uncaught TypeError: next is not a function
Как выделить при помощи класса текущее число, не выходит
добавляю...
currDay.getMonth() <= month
. Представьте, что следующий месяц - январь, год кончается. Что будет с вашим условием? Правильно, оно останется истинным. Навсегда. Лучше сделать так: проверяете равенство, без "меньше", а while заменяете на do-while - тогда числа предыдущего месяца, формально не подходящие под условие, всё равно будут обработаны, так как тело цикла выполняется до проверки условия.document.querySelectorAll('.restab').forEach((n, i) => {
n.id = `responsivetable${++i}`;
});
// или
for (const [ i, n ] of document.querySelectorAll('.restab').entries()) {
n.attributes.id.value = 'responsivetable' + (i + 1);
}
// или
const elems = document.getElementsByClassName('restab');
for (let i = 0; i < elems.length; i++) {
elems[i].setAttribute('id', 'responsivetable'.concat(-~i));
}
Basket.totalPrice.call(data)
. Но, повторюсь, это безумие. $('.reeder').click(function() {
const $box = $(this).closest('.box').toggleClass('none');
$box.parent().find('.box').not($box).addClass('none');
});
const $boxes = $('.box').on('click', '.reeder', e => {
$(e.delegateTarget).toggleClass('none');
$boxes.not(e.delegateTarget).addClass('none');
});
def printSinglyLinkedList(node):
if node != None:
printSinglyLinkedList(node['next'])
print(node['value'])
printSinglyLinkedList(d)
def reverseSinglyLinkedList(head):
prevNode = None
currNode = head
while currNode != None:
nextNode = currNode['next']
currNode['next'] = prevNode
prevNode = currNode
currNode = nextNode
return prevNode
function onlyOne(checkbox) {
for (const n of document.getElementsByName(checkbox.name)) {
n.checked = n === checkbox ? n.checked : false;
}
}
function onlyOne(checkbox) {
checkbox
.closest('.group')
.querySelectorAll('input[type="checkbox"]')
.forEach(n => n.checked = n.checked && n === checkbox);
}
...как мне правильно написать регулярку для jq метода find(), чтобы он...
data: () => ({
items: [...Array(5).keys()],
}),
methods: {
move(index, step) {
const items = [...this.items];
const newIndex = Math.min(items.length - 1, Math.max(0, index + step));
[ items[index], items[newIndex] ] = [ items[newIndex], items[index] ];
this.items = items;
},
// или
move(index, step) {
const { items } = this;
const newIndex = Math.min(items.length - 1, Math.max(0, index + step));
items.splice(index, 1, items.splice(newIndex, 1, items[index])[0]);
},
// или
move(index, step) {
const newIndex = Math.min(this.items.length - 1, Math.max(0, index + step));
if (index !== newIndex) {
const val = this.items[index];
this.$set(this.items, index, this.items[newIndex]);
this.$set(this.items, newIndex, val);
}
},
},
<div v-for="(n, i) in items">
<input v-model="items[i]">
<button @click="move(i, -1)">вверх</button>
<button @click="move(i, +1)">вниз</button>
</div>
не получается обратиться к геттеру <...> показывает null, хотя если вызвать store.getters, то данные есть
<компонент v-if="$store.getters.profile" />
//Подключаю хранилище import store from './store'; store.dispatch('getUser'); new Vue({ el: '#app', router: router, components:{ 'head-app':headImplant, 'footer-app':footer, 'sidebar-app': sidebar } });
new Vue({
store,
...
class App extends Component {
state = {
users: []
}
componentDidMount() {
fetch('https://jsonplaceholder.typicode.com/users')
.then(response => response.json())
.then(users => this.setState({ users }));
}
render() {
return(
<div className="App">
<table>
<tbody>
{this.state.users.map(n => (
<tr key={n.id}>
<td>{n.name}</td>
<td>{n.username}</td>
<td>{n.email}</td>
<td>{n.website}</td>
</tr>
))}
</tbody>
</table>
</div>
)
}
}
<select id="person"></select>
<select id="key"></select>
<span id="value"></span>
const data = [
{
"ФИО": "Иванов Сергей",
"Адрес": {
"Город": "Москва",
"Улица": "Пятницкая",
"Дом": "35",
},
},
{
"ФИО": "Сидоров Иван",
"Адрес": {
"Город": "Питер",
"Улица": "Ленина",
"Дом": "42",
},
},
];
const selects = [
Select('#person', data.map(n => n['ФИО'])),
Select('#key', Object.keys(data[0]['Адрес'])),
];
selects.forEach(n => n.addEventListener('change', onChange));
function Select(selector, options) {
const el = document.querySelector(selector);
el.append(...options.map(n => new Option(n)));
el.value = null;
return el;
}
function onChange() {
const [ person, key ] = selects.map(n => n.value);
if (person && key) {
const value = data.find(n => n['ФИО'] === person)['Адрес'][key];
document.querySelector('#value').textContent = value;
}
}
const getUnique = arr => Array
.from(arr.reduce((acc, n) => acc.set(n, acc.has(n)), new Map))
.reduce((acc, n) => (n[1] || acc.push(n[0]), acc), []);
const result = getUnique(arr);
const getByCount = (arr, checkCount) => Array
.from(arr.reduce((acc, n) => acc.set(n, -~acc.get(n)), new Map))
.reduce((acc, n) => (checkCount(n[1]) && acc.push(n[0]), acc), []);
const result = getByCount(arr, count => !~-count);