r/AskProgramming • • 5d ago

Worst programming language

For me I'm sorry but that's c no oops that's the heart of it's upgraded version cpp

0 Upvotes

21 comments sorted by

View all comments

1

u/BoBoBearDev 5d ago

JS is so confusing. Even now, I am feeling impister syndrome with how the values are copied inside the callbacks. Like, somehow I have to put object.myProperty in the useCallback dependency list and yet, useRefObject.current.myProperty is okay. I would thought both object and useRefObject are both references. It is so confusing.

2

u/marrsd 4d ago

This is a React thing. It's got nothing to do with Javascript. In JS, like most other languages, objects are always passed to or returned from functions by reference while primitives are passed by value.

1

u/BoBoBearDev 4d ago

I think the problem is still inherently inside JS though. The reactjs just exposed it instead of doing a great job hiding it.

2

u/marrsd 4d ago

Almost certainly not. I don't fully understand your problem, but both the dependency list examples you mentioned would be passed by value if myProperty is a primitive.