Neat little trick to conditionally add a key and value to an object:
1 2 const someBoolean = true; ...(someBoolean && {key: "value"})
1 2
const someBoolean = true; ...(someBoolean && {key: "value"})
Simple snippet to get query parameters
Increase dashed/dotted border width
Comments powered by Disqus.
Simple snippet to get individual parameters from the url. 1 2 3 4 5 6 const getUrlParameter = (name) => { name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); var regex = new RegExp('...
This function returns 504 after time has passed. Instead of letting the user wait for the API to timeout which could take 60 seconds, it’s better to give the user feedback after a few seconds inste...
This will create a new object with each gender grouped by key using the reduce function. Array of objects to be grouped by gender: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 2...