<script> var array = []; function func(a, b, c) { var i = array.length; i = array[i] = {}; i[a] = {}; i[a][b] = c; } func("text1", "text2", "text3"); document.write(JSON.stringify(array, null, 4)) </script>