Skip to content
Advertisement

How to filter undefined values from Array JavaScript?

The code below is working fine it’s filtering duplicate values from Array but it’s not filtering undefined Values console.log([67, undefined]). i want to filter undefined values and duplicate values from array and output in options values as selected. I would be grateful for any help.

i have two datatable with drag and drop functionality. each row of datatable contain the IDs. when i drag the row of table 1 into table 2. the data stored into the Array. i have the addArray function for push the IDs into an Array there also filtering the duplicate IDs and make it uniqueArray. now i want to create the Select option Element which containing the iDs as a value. I want if i drag out a value from Array then the select options update automatically and delete the option from it…?

js

JavaScript

Advertisement

Answer

You do not have a filter. Why not just test

JavaScript

if 0 is not a possible value, remove && value !== 0

JavaScript

You can simplify

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement