80. implement your own URLSearchParams
Share
hard? - accepted / - tried
When we want to extract parameters from query string, URLSearchParams could be very handy.
Can you implement MyURLSearchParams
which works the same ?
const params = new MyURLSearchParams('?a=1&a=2&b=2')params.get('a') // '1'params.getAll('a') // ['1', '2']params.get('b') // '2'params.getAll('b') // ['2']params.append('a', 3)params.set('b', '3')params.toString() // 'a=1&a=2&b=3&a=3'
There are a few methods on URLSearchParams, please implement them all.
Related Lists
implement it by yourself