const key = 'prop';
const val = 1;const result = array.flatMap(n => n.filter(m => m[key] === val));
// или
const result = array.reduce((acc, n) => (
n.forEach(m => m[key] === val && acc.push(m)),
acc
), []);
// или
const result = [];
for (const n of [].concat(...array)) {
if (n[key] === val) {
result[result.length] = n;
}
}
const group = (arr, key) =>
arr.reduce((acc, n) => {
const k = n[key];
(acc[k] = acc[k] || []).push(n);
return acc;
}, {});
const result = Object.values(group(array, 'prop'));function group(data, key, val = n => n) {
const getKey = key instanceof Function ? key : n => n[key];
const getVal = val instanceof Function ? val : n => n[val];
const grouped = {};
for (const n of data) {
(grouped[getKey(n)] ??= []).push(getVal(n));
}
return grouped;
}const groupedBySign = group([ 0, 1, 2, 3, -10, -20, -30, 0 ], Math.sign);const groupedByParity = group(Array(10).keys(), n => [ 'чётные', 'нечётные' ][n & 1]);const chars = group(
'ABC123?!+',
n =>
n.toLowerCase() !== n.toUpperCase() ? 'буква' :
Number.isInteger(+n) ? 'цифра' :
'другое'
);<input name="xxx" value="69">
<input name="xxx" value="187">
<input name="xxx" value="666">
<input name="yyy" value="0">const values = group(document.querySelectorAll('input'), 'name', 'value');const result = Object.values(Object.groupBy(array, n => n.prop)); upload_url c полем file, содержащим файл в формате multipart/form-dataserver, photo и hash
const obj = array.reduce((acc, n, i) => (
acc[`filter${i + 1}`] = { ...baseFilter, prop: n },
acc
), {});const obj = {};
for (const [ i, n ] of array.entries()) {
(obj['filter' + (-~i)] = Object.assign({}, baseFilter)).prop = n;
}const obj = {};
for (let i = 0; i < array.length;) {
const subobj = { prop: array[i] };
for (const k in baseFilter) {
subobj[k] = baseFilter[k];
}
obj['filter'.concat(++i)] = subobj;
}
const res = items.filter(o => dictionary.some(v => v.code == 'seller' && v.id == o.role)); const names = {
nullable: "inn,kpp,ogrn,organizationName,phone,email,webAddress,address,accreditationState,description"
.split(","),
dates: "ogrnIssueDate,accreditationDate,accreditationEndDate"
.split(","),
};
const data = {};
for(let i = 0; i < names.nullable.length; i++) {
const prop = names.nullable[i];
data[prop] = fields.hasOwnProperty(prop) ? fields[prop] : null;
}
for(let i = 0; i < names.dates.length; i++) {
const prop = names.dates[i];
data[prop] = fields.hasOwnProperty(prop) ? convertToDtoDate(fields[prop]) : null;
} 

Shift + Alt + Down или Shift + Alt + Up[
{
"key": "ctrl+shift+u",
"command": "editor.action.transformToUppercase",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+l",
"command": "editor.action.transformToLowercase",
"when": "editorTextFocus"
}
] The declaration syntax for a DECIMAL column is DECIMAL(M,D). The ranges of values for the arguments are as follows:
M is the maximum number of digits (the precision). It has a range of 1 to 65.
D is the number of digits to the right of the decimal point (the scale). It has a range of 0 to 30 and must be no larger than M.
function sum(arr) {
var val = arr.pop();
if( !val ) return 0;
if( Array.isArray(val)) return sum(val) + sum(arr);
return val + sum(arr);
}let array = [];
// так как sum_2 уничтожает исходный массив, для адекватности
// добавил переинициализацию массива исходных данных
function sum_1(arr) {
if (!arr.length) {
return 0;
}
let val = arr[0];
if (val instanceof Array) {
val = sum_1(val);
}
return val + sum_1(arr.slice(1));
}
function sum_2(arr) {
var val = arr.pop();
if (!val) return 0;
if (Array.isArray(val)) return sum_2(val) + sum_2(arr);
return val + sum_2(arr);
}
console.time('init array');
for (let i = 0; i < 1000; i++) {
array = [
[1, 4],
[11],
[3, 5, 7]
];
}
console.timeEnd('init array');
console.time('eval');
for (let i = 0; i < 1000; i++) {
array = [
[1, 4],
[11],
[3, 5, 7]
];
eval(JSON.stringify(array).replace(/[^\d]+/g, '+') + '0') // 31
}
console.timeEnd('eval');
console.time('sum recursion 1');
for (let i = 0; i < 1000; i++) {
array = [
[1, 4],
[11],
[3, 5, 7]
];
sum_1(array);
}
console.timeEnd('sum recursion 1');
console.time('sum normal');
for (let i = 0; i < 1000; i++) {
array = [
[1, 4],
[11],
[3, 5, 7]
];
[].concat.apply([], array).reduce(function(res, item) {
return res + item;
})
}
console.timeEnd('sum normal');
console.time('sum recursion 2');
for (let i = 0; i < 1000; i++) {
array = [
[1, 4],
[11],
[3, 5, 7]
];
sum_2(array);
}
console.timeEnd('sum recursion 2');