When an object is assigned to a variable, will modifying the variable modify the original object?

This is similar to the previous blog post except this is more direct. The answer is “Yes” for all tested languages except C and C++. This may seem trivial until you meet a situation where the same original object is shared across requests/sessions, like a public static variable in Java or an incorrectly scoped Javascript …

Does modifying objects passed in to functions modify original object?

As per title, ran this across various languages. Results are mixed, but IMHO, it seems unsafe to design your functions/methods this way. It would be better to pass in the object, compute the changes without modifying the object, return the computed changes and assign it back to the original variable. Below are sample code snippets …