Find duplications in array using Lodash (JavaScript)

Lodash is my favorite JavaScript library that includes many useful data manipulation utilities in functional programming style. It can run in Node.js and browsers.

The below snippet is an example of using 2 functions filter and includes to find duplications in an array.

const _ = require('lodash')

const values = [1,2,2,3,4,1]
const duplications = _.filter(values, (value, i) => {
 return _.includes(values, value, i + 1)
})

console.log(duplications) 
// => [1, 2]

Explain:

(more…)

Refresh Cached Progressive Web App

Progressive Web App (PWA) is getting very popular these days in 2020 because it provides a greater web experience and responsiveness, especially for interactive application. Part of the power comes from various caching strategies which allow smoother experience during interrupted network and even offline operation (partially or fully depending the type of application of course).

There is a bit of downside though. The cached version might stick around longer than wanted when there is a newer version available. Sometimes a force refresh (F5) might not be effective. Usually it will be eventually updated, but if you want to get the latest update right away, that can be done quite easily as the following example:

  1. In Chrome browser, on the PWA web page, click on the lock icon next to the address to go to Site settings
(more…)