how to copy arrays, without reference in javascript code example Example: javascript clone array without reference var tempArray = JSON.parse(JSON.stringify(mainArray));