Home Javascript How to remove undefined value from jquery array?

How to remove undefined value from jquery array?

by Shahriar Sagor

Today now in this post i will show you how to remove undefined value from jquery array. If we have jquery or javascript array also with lots of undefined value and then if we want to remove all undefined value from array. We can remove the undefined items from our array without by using each loop we have to just use filter, I would like to give you the example of how to remove undefined element from javascript array. so, let’s start and see the bellow example.

<script type="text/javascript">
    var obj = ['3','3','5',undefined,'hi'];
    obj = obj.filter(function(e){return e}); 
    console.log(obj);
</script>

Read Also : Laravel Where Clause with Mysql Function Example

Thanks for read. I hope it help you. For more you can follow us on facebook.

close

You may also like