map() মেথড ব্যবহার করে দুটি সমান দৈর্ঘ্যের অ্যারে থেকে অবজেক্টের অ্যারে (নেস্টেড অ্যারে) বানানো যায়।
উদাহরণ
var firstArray = ['John', 'David', 'Bob'];
var secondArray = ['Mike', 'Sam', 'Carol'];
var arrayOfObject = firstArray.map(function (value, index) {
return [value, secondArray[index]];
});
console.log("The First Array="); console.log(firstArray);
console.log("The Second Array="); console.log(secondArray);
console.log("The mix Of array object="); console.log(arrayOfObject);
কমান্ড: node fileName.js
আউটপুট
PS C:\Users\Amit\javascript-code> node demo190.js The First Array= [ 'John', 'David', 'Bob' ] The Second Array= [ 'Mike', 'Sam', 'Carol' ] The mix Of array object= [ [ 'John', 'Mike' ], [ 'David', 'Sam' ], [ 'Bob', 'Carol' ] ]