I am writing a (client-side) JavaScript library (a node/angular module). In this library, I make use of the URLSearchParams class.
const form = new URLSearch
If we want to support big range of nodejs versions in our application , we could use some dirty code like this :
nodejs
if(typeof URLSearchParams === 'undefined'){ URLSearchParams = require('url').URLSearchParams; }
Note: It is not best practice to require with a condition.
require