Is it normal that when I use splice on temp, mainArray is also modified ?
console.log(mainArray);
var temp = mainArray;
temp.airfares.splice(index, 1);
This is because temp is not an entirely new array, just a reference to mainArray. You need to make a copy.
To easily make a copy of an array, using Array.prototype.slice() is common. Note that it will not copy each element, but will copy the array itself (so you can push or remove elements later).
For example:
var data = [1, 2, 3, 4, 5];
document.getElementById("original").textContent = JSON.stringify(data);
var ref = data;
var copy = data.slice();
// Add some values to data, ref will change but copy won't
data.push(6, 7, 8);
document.getElementById("ref").textContent = JSON.stringify(ref);
document.getElementById("copy").textContent = JSON.stringify(copy);
<pre id="original"></pre>
<pre id="ref"></pre>
<pre id="copy"></pre>
.airfaresproperty.