Skip to content

Tag: javascript

How to use both props and mounted() with NuxtJS?

I’m new to NuxtJS and I’d want to use window.addEventListener on a particular component used on my page, but also remove the event when we change the page. In React, I’d do something like this: But, how do I do the same behaviour with NuxtJS 3? The problem is how do I remove the event once t…

JavaScript: Search string from position

JavaScript has two useful methods, both which nearly do what I need. String.prototype.indexOf() will search for a substring and return its position. It has an optional position parameter which is the starting point of the search, so you can easily find the next one. String.prototype.search() will search a str…