Javascript examples for Data Type:undefined
Use if statement to check undefined values
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {/*from w ww. ja va 2 s . co m*/ var undef; var arr = [1,2, undef, 3, 4, undef,'',undefined,"",' ']; var temp = []; for (var i=0; i < arr.length; i++) { if ( arr[i] ) { temp.push(arr[i]) } } console.log(temp); arr = temp; temp = null; console.log(arr); }); </script> </head> <body> </body> </html>