const { Pure } = require('pure-array'); const yourArray = [1, 2, 3]; // try add existed number or doesn't console.log(Pure(yourArray, 3))
Push if doesn't exist or remove if exist your element from array.