Property 'yPos' does not exist on type 'Element'

I’m refactoring an old project and converting it from javascript to typescript. In one of my functions I am getting the position of an element using yPos (yPos seems to be enabled only after the element is dragged), the intent is to drag it to another position and drop it, but when I try to… Read More Property 'yPos' does not exist on type 'Element'

Get the last element of an anonymous HTMLCollection

My vanilla Javascript code contains many constructs like this: var foo = document.getElementsByClassName("foo")[0]; This works well whenever I want the first instance of foo (or when there is only one instance of foo). But, what if I want the last instance of foo? I can of course do: var fooCollection = document.getElementsByClassName("foo"); var foo =… Read More Get the last element of an anonymous HTMLCollection

Javascript filter over HTMLCollection

I want to get particular query params from all the js files which have been loaded by the browser. My query params reside in the js file named script.js(ex: https://abcd.com/script.js?code=123). In the browser console, I tried like this: const scripts = document.getElementsByTagName("SCRIPT") scripts.filter((script) => { return script.src.includes("script.js?code=")}) But this returns the error Uncaught TypeError: document.getElementsByTagName(…).filter… Read More Javascript filter over HTMLCollection