Angular πŸ‡ΊπŸ‡¦ - practical notes
1.63K subscribers
1.6K photos
1 file
532 links
Angular - practical notes

This group is for posting practical notes for Angular developers. Mostly all posts are for quick implementation https://t.me/angular_practical_notes (Commenting on posts only in ENG and UA langs here). Welcome!
Download Telegram
js.reduce(): Group an array of objects by a specified property

#js #reduce

βœ… Example:

function GroupBy(array, property) {
return array.reduce((acc, obj) => {
let key = obj[property];
acc[key] = acc[key] || [];
acc[key].push(obj);
return acc;
}, {});
}

const users = [
{ name: "Bytefer", age: 30 },
{ name: "Kakuqo", age: 28 },
{ name: "Chris", age: 28 },
];

const groupedUsers = GroupBy(users, "age");
// groupedUsers:
// {
// '28': [
// { name: 'Kakuqo', age: 28 },
// { name: 'Chris', age: 28 }
// ],
// '30': [
// { name: 'Bytefer', age: 30 }
// ]
// }
πŸ‘1
js.reduce(): Runs an array of promises in series

#js #reduce
js.reduce(): Serialize query parameter object

#js #reduce

βœ… Example:
function StringifyQueryParam(queryParam = {}) {
return Object.entries(queryParam)
.reduce(
(t, v) =>
`${t}${v[0]}=${encodeURIComponent(v[1])}&`,
Object.keys(queryParam).length ? "?" : ""
)
.replace(/&$/, "");
}

const queryString = StringifyQueryParam({
name: "bytefer",
email: "bytefer@gmail.com",
});
// queryString: '?name=Bytefer&email=bytefer%40gmail.com'
⚠️ Signals in Angular (new approach of reactivity)

#angular #signals

🚩 > Angular 16

βœ… Link: https://medium.com/@simon.sharp_25406/signals-in-angular-3dc2c97ce5a6