DEV Community

Discussion on: Understanding the Difference Between Reference and Value in JavaScript

Collapse
 
val_baca profile image
Valentin Baca • Edited

Correct. structs in several languages behave similarly (C, Go, Crystal). The cost of copying becomes larger as the struct becomes larger, which is where pointers come in. Then references were made as a safer alternative to pointers. (obviously glossing over details here)

By the way, I think you mean instances when you wrote "classes are passed by "a copy of a reference""

In the end it all comes down to knowing how pointers work. So many programmers think that if they're not coding in C or C++ then they can just not learn how pointers work since they're dealing with """references"""

Knowing what is exactly copied is incredibly important in every language.

Thread Thread
 
miketalbot profile image
Mike Talbot ⭐

Ooops... Quite right, instances of classes.