I have many js variables some of them is ok, some of them cant be set and makes them undefined, and undefined appears in html page, and this I don't want to happen.
How the js is now.
<script>
var externalData = 'data,data,data\n'
+ 'data,data,data\n'
+ 'data,data,data\n'
+ 'data,data,data\n'
+ 'data,data,data';
// split the string into rows, and split each row into cells
var parsed = externalData.split('\n').map(function(row) {
return row.split(',');
});
</script>
</html>
<script>
// I try this but not working.
if ( parsed[4][6] !== undefined )
{
var parsed[4][6] = null;
}
</script>
<script>document.write(parsed[0][0]);</script>
<script>document.write(parsed[4][6]);</script>
The is will output in the browser:
data undefined
The parsed[0][0] is ''data'' but the parsed[4][6] not exist in the table. well, I don't want the user to see that is undefined, but I want to see just nothing.
For example this:
data
instead of this
data undefined
I can remove undefined by just remove the document.write(parsed[4][6]); but I don't want to do this, I want to keep this in the page, and I don't want to modify the data-table above.
parsed[4][6] !== undefinedwhich should beparsed[4][6] === undefined, and thevarat the start of the next line of code should also not be present. After making these changes, it should work.