Difference between ?:, ?! and ?=

The difference between ?= and ?! is that the former requires the given expression to match and the latter requires it to not match. For example a(?=b) will match the “a” in “ab”, but not the “a” in “ac”. Whereas a(?!b) will match the “a” in “ac”, but not the “a” in “ab”. The difference … Read more

Clearing my form inputs after submission

Your form is being submitted already as your button is type submit. Which in most browsers would result in a form submission and loading of the server response rather than executing javascript on the page. Change the type of the submit button to a button. Also, as this button is given the id submit, it … Read more

Array Mapping in AngularJs

Make a map of your data that looks like this: You can do this by looping over your tags and adding a new property to an object. reduce lets you do this without creating any extra variables. Then, you can select names from your newly created object using the [] notation: tagMap[1] returns “pyhton”. Expand … Read more

jQuery replace one class with another

To do this efficiently using jQuery, you can chain it like so: For simplicities sake, you can also do it step by step like so (note assigning the jquery object to a var isnt necessary, but it feels safer in case you accidentally remove the class you’re targeting before adding the new class and are … Read more

command not found: jest

Jest is installed, but is likely in your ./node_modules/.bin directory. You can append that to your command ./node_modules/.bin/jest –updateSnapshot. Since you already have jest as a scripts command in your package.json you can also run it with npm test — –updateSnapshot. npm automatically adds ./node_modules/.bin to your path. update: Newer versions of yarn will resolve node module bin scripts, so you can also just run yarn jest {cmd} and it … Read more

Load Image from javascript

you can just append another hidden img element and swap them in onload event. Or use single image element and use javascript like: this code should preload the image and show it when it’s ready