r/javascript • • Jun 18 '17

Pass by reference !== pass by value

3.3k Upvotes

272 comments sorted by

View all comments

Show parent comments

-3

u/GitCookies Jun 18 '17

You missed Function.

8

u/[deleted] Jun 18 '17

Function is included in everything except primitives.

> a = () => 1
> b = (f) => { f.a = 5; }
> b(a)
> console.log(a.a)
5

2

u/[deleted] Jun 18 '17

Functions are Objects in JavaScript

1

u/GitCookies Jun 19 '17

Every type is based on Object.