I have two arrays which I want to match them together as below:
Code:
var a = [1, 2, 3, 4];
var b = [5, 6, 7, 8];
This method works:
Code:
for ( var i = 0; i < 4; i += 1 ) {
	(function(z) {
		var d = x(a[z], b[z]);
	})(i);
}

function x(j, k) {
	console.log(j, k);
};
But I also want this method to work as well:
Code:
for ( var i = 0; i < 4; i += 1 ) {
	(function(z) {
		var d = x.y(a[z], b[z]);
	})(i);
}

var x = {
	y: function(j, k) {
		console.log(j, k);
	}
};
Upon testing it throws error.
I woulds use the second method because most of my JavaScript code adopting the pattern.