Merge 2 uneven list with Javascript


var x = [1,3,5,9];
var y = [2,4,6,7,8];

var p1 = 0;
var p2 = 0;

while(p1 < x.length || p2 < y.length){

	if(typeof x[p1] == 'undefined'){
		console.log(y[p2]);
		p2++;
		continue;
	}

	if(typeof y[p2] == 'undefined'){
		console.log(x[p1]);
		p1++;
		continue;
	}

	if(x[p1] < y[p2]){
		console.log(x[p1]);
		p1++;
		continue;
	}

	if(x[p1] > y[p2]){
		console.log(y[p2]);
		p2++
		continue;
	}

}