Skip to content

Tag: ecmascript-6

array.every() works on only first element

I have an array I need a function call to be looped on every element of array, but somehow after executing function for first element ‘shippingError’, the loop stops. Below is the function call And the function that is executed It sometimes, works on array element, but mostly stops after first ele…

target child div of ID in JavaScript and CSS

I’m having difficulty targeting the child div of id=”videoContainer” and changing its style Answer You can use querySelector with the direct child operator > (and maybe first with :first-child if you have more than one child div) like this: object-fit: contain will force you video to scal…

How are IIFEs useful post ES6?

I’m learning JavaScript and I understand the general function types, closures, etc. But with IIFEs my initial reaction was “if its immediately invoked, why not just inline it”. So I went and read this article that describes “4 Practical Use Cases” for IIFEs. However, two of which…

Having trouble displaying object property

I’m building a small pokedex using PokeAPI. I’m retrieving data from an endpoint and building my own object. The function that I’ve built for the latter runs on page load as follows: I’m able to console log the object and traverse it in devtools, and also able to JSON stringify it and …