r/AskProgramming • • Oct 12 '26

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 Oct 12 '26

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 Oct 13 '26

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 Oct 13 '26

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 Oct 13 '26

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.