JavaScript.- Quick Helper
JavaScript.- Quick Helper
JavaScript helper
Filter and order
1
this.recordTypes = res.filter(x => x.isBusinessRecord && x.order !== null).sort((a, b) => a.order! - b.order!);
Find a single result
1
this.formulaExecutionResult.recordResults.find(r => r.recordId == this.formulaExecutionResultSelectedRecord).results
Find shared elements by property
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const arr1 = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' },
{ id: 3, name: 'Charlie' }
];
const arr2 = [
{ id: 2, name: 'Bob' },
{ id: 4, name: 'David' }
];
// Find elements in arr1 that share the same `id` with arr2
const shared = arr1.filter(item1 =>
arr2.some(item2 => item2.id === item1.id)
);
This post is licensed under CC BY 4.0 by the author.