You can do it in multiple ways:
Option 1: Pure JavaScript nested loops
You can do it with pure JavaScript just with two nested loops. It is relatively slow on big arrays, but quite simple.
Option 2: Pure JavaScript loop with preindexation
You can do it preindex one of arrays to fast access to it.
Option 3: Using special library
As an alternative you can use special SQL or LINQ (as mentioned in the other answer) libraries, e.g. Alasql, where the library automatically creates index on the second array to faster access to avoid unnecessary loops.
Performance: You can compare the speed of all three variants on joining 10000 x 10000 arrays (simple nested loops and with preindexation) in this jsPerf test. Option 2 is fastest.
See the working snippet below with all three options or play with it in jsFiddle.
(Disclaimer: I am an author of Alasql)
var Array1 = [{name:'name1',value:7},{name:'name2',value:5},{name:'name3',value:6}];
var Array2 = [{name:'name1',value:3},{name:'name2',value:4},{name:'name3',value:8}];
// 1. Pure JavaScript option with nested loops
var Array3 = [];
for(var i=0;i<Array1.length;i++) {
for(var j=0;j<Array2.length;j++) {
if(Array1[i].name == Array2[j].name) {
Array3.push({value:Array1[i].value * Array2[i].value});
break;
}
}
}
document.getElementById("res1").textContent = JSON.stringify(Array3);
// 2. Preindexation version
var idx = {};
for(var j=0;j<Array2.length;j++) {
idx[Array2[j].name] = Array2[j].value;
}
var Array3 = [];
for(var i=0;i<Array1.length;i++) {
Array3.push({value:Array1[i].value * idx[Array1[i].name]});
}
document.getElementById("res2").textContent = JSON.stringify(Array3);
// 3. SQL library option
var Array3 = alasql('SELECT Array1.[value]*Array2.[value] AS [value] \
FROM ? Array1 JOIN ? Array2 USING name',[Array1, Array2]);
document.getElementById("res3").textContent = JSON.stringify(Array3);
<script src="http://alasql.org/console/alasql.min.js"></script>
<p>Pure JavaScript nested loops: </p><div id="res1"></div>
<p>Pure JavaScript preindexation: </p><div id="res2"></div>
<p>Alasql version: </p><div id="res3"></div>