<script>
function makeArray(arg1, arg2){
return [ this, arg1, arg2 ];
}
alert(window.makeArray('one', 'two'));
</script>
Question:
The output of the above script is: [Object Window], one, two, If I changed return [ this, arg1, arg2 ]; to return ( this, arg1, arg2 ); the output is: two. So what is the difference between return[] and return()?
forhead in general:for(i=0, a=[]; i<10; i++)returnis well documented, but no one ever wrote up the bad things that happen if you inadvertently try to combine them.return (a, b)kinda looks like exactly a function call with a list of arguments. Except that it isn't.