I came across some strange (legacy?) JS syntax this morning which boiled down to: var example = "String".Property = "Value";
Before altering this code, I couldn't find a valid case for this implementation that I am aware of...
var example = "String".Property = "Value";
console.log(example);
"String".Property = "Value";
console.log("String".Property);
console.log(String.Property);
What actually happens to "String".Property in the first part of the above snippet, does it just get discarded immediately after being assigned ?
"String"is a literal string, and since you don't keep a reference to it it will be garbage collected whether you assign a property to it or not.