有什么方法可以检查Javascript变量的内存地址? [英] Is there any method to check memory address of Javascript variable?
问题描述
是否有可能在现代Javascript中找到JavaScript变量的内存地址?或Typescript变量的地址.
Is it possible to find the memory address of a JavaScript variable in modern Javascript? Or address of Typescript variable.
我对按值传递和按引用传递感到困惑,使用内存地址很容易理解现实.现在我们有了ES8和Typescript,但仍然无法获取变量和对象的内存地址.
I am confused about the pass by value and pass by reference, using memory address it is easy to understand the reality. Now we have now ES8 and Typescript but still unable to get memory address of variable and Object.
推荐答案
It's more or less impossible - Javascript's evaluation strategy is to always use call by value, but in the case of Objects (including arrays) the value passed is a reference to the Object, which is not copied or cloned. If you reassign the Object itself in the function, the original won't be changed, but if you reassign one of the Object's properties, that will affect the original Object.
这篇关于有什么方法可以检查Javascript变量的内存地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!