function fibi(total, i0, i1, index) {
if (! i0) {
i0 = 1;
index = 1;
} else if (! i1) {
i1 = 1;
index = 2;
} else {
[i0, i1] = [i0 + i1, i0];
index++;
}
console.log(i0);
if (index < total) return fibi(total, i0, i1, index);
}
// Использовать:
fibi(5)
/*
1
1
2
3
5
*/
Мне это нужно под JavaScript
ffmpeg \
-i music.mp3 \
-filter_complex "aformat=channel_layouts=mono,showwavespic=s=640x120" \
-frames:v 1 \
waveform.png
const object1 = {
habr: 'QnA',
google: 'search',
};
for (const [key, value] of Object.entries(object1)) {
console.log(`${key}: ${value}`);
}
// "habr: QnA"
// "google: search"
const fields = ['address', 'status', 'data'];
let myAdressPoints = Object.fromEntries(str.split('; ').map((v, i) => [fields[i], v]))
for const [name, button] of Object.entries(buttons) {
button.addEventListener('click', () => show( this[name + 'Items']);
}
const buttons = {};
'all,love,chef,girl,boy,grandma,grandpa'
.split(',').forEach((name) => buttons[name] = menuWrapper.querySelector('.' + name));
Использовать потом, например, вместо girlButton
— buttons.girl
options
свойство categoryPercentage
со значением от 0 до 1.sum
— тут это будет сумма. К ней добавляется очередной элемент, умноженный на 1 или на 0, в зависимости от четности числа. Четность определяется младшим битом: если 1, то нечетное. alert(arr.reduce((sum, n) => sum + n * !(n & 1), 0))
Аккумулятором ведь выступает 1 объект в этом массиве.
{}
[ {id: 'a'}, {id: 'b'}, {id: 'c'} ]
{
a: {id: 'a'},
b: {id: 'b'},
c: {id: 'c'}
}