Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 | var globalVariable = {}; globalVariable.arrayOne = [1, 2, 3]; var referenceVariable = globalVariable.arrayOne; console.log('Size of arrayOne: '+globalVariable.arrayOne.length); console.log('Size of referenceVariable: '+referenceVariable.length); // Add something to the referenceVariable... referenceVariable.push(72); console.log('EFFECT OF CALL BY REFERENCE'); console.log('Size of referenceVariable: '+referenceVariable.length); console.log('Size of arrayOne: '+globalVariable.arrayOne.length); |
Output:
Size of arrayOne: 3
Size of referenceVariable: 3
EFFECT OF CALL BY REFERENCE
Size of referenceVariable: 4
Size of arrayOne: 4