DEV Community

Discussion on: Pass By Reference Vs Pass By Value

Collapse
 
smlka profile image
Andrey Smolko

Damn, this is so brilliant comment!!!
Exactly, there are just NOT any ways to mutate primitive data type value:

let obj = {}
let obj_c = obj
let str = ''
let str_c = str
// mutate value in obj
obj[0] = 1
obj_c // {0: 1}
// try mutate value in str
str[0] = 1 // or try to mutate value in str in your own manner
str // ''
str_c // ''
Enter fullscreen mode Exit fullscreen mode