title: In javascript, array is showing 'pass by value' behavior instead of 'pass by reference'
body: <p>I know that array being an object in javascript, makes it non-primitive data types, which by default makes it a pass by reference.
  Now this is true in most of the used cases I have encountered however the code I am sharing shows a weird behavior which I am not understanding and it seems more like a 'pass by value type'.</p>
  
  <pre><code>var arr = ['a','b','c']
  /*
  function addArr(ar){
      ar.push('d')
      return ar
  }
  
  console.log(addArr(arr))  // ['a', 'b', 'c', 'd']
  console.log(arr)          // ['a', 'b', 'c', 'd']
  */
  
  //the above output is expected behavior for an Array object
  
  
  
  function changeArr(ar){
  
      console.log(ar)   //1-// ['a', 'b', 'c']
      ar = ['12','11']
      console.log(ar)   //2-// ['12', '11']
      return ar
  }
  
  console.log(changeArr(arr)) //3-// ['12', '11']
  console.log(arr)            //4-// ['a', 'b', 'c']
  
  //now I expect the forth console output to be  ['12','11'] here because it is an object
  </code></pre>