I'm developing window application for comparing source code with node-webkit and I want to check null function.
my code is
function click1() {
if(swap == true)
var lines1 = $('textarea1').val().split('\n'); //compare1
var lines2 = $('textarea2').val().split('\n'); //compare2
if (lines1.length == lines2.length) {
for (var i=0;i<lines1.length;i++) {
if(lines1[i] == lines2[i]) {
var keys = lines1[i].match(/\b[\w\d]*/g);
if(keys[0] == null) { //**problem line**
alert('This line is null');
} else {
alert(keys[0]);
}
}
}
If i execute this click event, error occured.
Uncaught TypeError : cannot read property '0' of null
How I can fix this problem..
help me
ps. I tried keys[0] === null, typeof keys[0] == 'null', !keys[0] etc...