I was trying to do a querySelector by text, trying to find elements with certain text content of an element. It turns out you can do that with XPath without much effort. With any XPath expression you can think of. Query the elements In my particular use caes, the HTML looks like this: Use your […]
Here’s how to order an array of objects by multiple property values. I want to order my friends: First the oldest. If they have the same age, first the tallest. We’ll use Array.prototype.sort() Result As you can see the friend 4 and 5, who have the same age have been sorted by tallest first.
If you’re debugging a LocalStorage issue and want to use a call stack to know what or who is triggering a localstorage get or set you can define a proxy function. The following snippet will overwrite the window.localStorage It has the same functions but adds a console.log and debugger before them.
Here’s an obvious bit of code (obvious when you know about it) 🤦🏻♂️
How to create a clone of a Vue object without the bindings?