Javascript is pass-by-value, but sometimes the value itself is the reference. In case of arrays and objects, Javascripts mimics the behaviour of pass-by-reference. See it being explained with a nice Harry Potter example

Video Explanation by Arnav Gupta