How to prove that function in js is a reference type?

146 0
var obj = {};
var obj2 = obj; = 'jason';
console.log(obj);//Object {name:"jason"}
console.log(obj2);//Object {name:"jason"}

The above code can prove that the object is a reference type

How to prove function.


I used name.

 var a = function(){};
 var b = a; = 'jason';

This is why.

2 Answers

61 1

This isn't the same reason, because function is also an object.

96 3

If I say all null types are reference types ( except and undefined ), do you want to trust.