Skip to content

Category: Questions

How to extend function in JS? [closed]

I have the following function: private getSquareBoundRectangleElements(elements: HTMLLIElement[] | SVGElement[]): number[] { let squares: number[] = []; elements.forEach((element) => { …

loop document.getElementsByClassName

I should loop document.getElementsByClassName but first doing a check. For just one element I would do this: But I have to repeat it for more elements and I never know how many there are. I would need such a loop but with the verification document.getElementsByClassName (‘lazyload img-responsive wp-post…

Creating an array by nested map with filtering

I have data like above, I want to make list of properties which has isMain property is true like the example below. How can I best do this with ES6? expectation ==> Answer You need to flat the array and then use the filter method to get your desired items from nested array, this will work even if you have

angular data modify before send the service

I need to modify my object. please check below function The item, included 3 values: code, avCode, ageCode. When I send the ‘item’ all three values pass to the service . According to my requirement I need to send only code and avCode. how can I modify ‘item’ before pass to service. I a…