For it to be pass by reference you need to change boo inside fun(), but you are changing a field of boo.bar using the boo address passed by value.
When JavaScript starts having pass by reference, this code will hold true. Until then it won't, regardless how people re-invent CS concepts on HN.
function fun( boo ) { boo = { bar: 42 } } function main() { let foo = null; console.log( "Before call:", foo); fun( foo ); console.log( "After call:", foo ); } main();
Before call: null After call: { bar: 42 }
For it to be pass by reference you need to change boo inside fun(), but you are changing a field of boo.bar using the boo address passed by value.
When JavaScript starts having pass by reference, this code will hold true. Until then it won't, regardless how people re-invent CS concepts on HN.
This will log: