3 ms·
Ohai. Author here. That’s indeed one of the trip-wires. So is that any kind of prototype is lost. The point of the structured clone algorithm is to make values
by dassurma 9y ago
Ohai. Author here. That’s indeed one of the trip-wires. So is that any kind of prototype is lost.
The point of the structured clone algorithm is to make values transferable to other realms, so functions are actively ignored. Most of the time, I think that is “good enough”.
- deleted 9y ago[deleted]
- shkkmo 9y agoCan you fix your first statement: "JavaScript passes everything by reference" which is incorrect? see: https://jsfiddle.net/t73ykuj0/ https://jsfiddle.net/t73ykuj0/
- zakember 9y agoCan you please explain why this behavior is happening in this jsfiddle, or point me to a link that can help me understand this better?
- shkkmo 9y agoThe term for what Javascript does is pass-reference-by-value or pass-by-sharing: https://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_sharing https://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_sh...
- ghusbands 9y agoYou might have missed the main thread pointing out that your claim that "JavaScript passes everything by reference" or is call by reference is wrong in every way. Javascript is call by value, those values can be strings, numbers and references to objects and arrays and such. "Call by reference" is very specific terminology that means that when you run somefunction(n), the caller's variable, n, might get entirely changed, even if it's just a number.