有什么方法可以检查Javascript变量的内存地址? [英] Is there any method to check memory address of Javascript variable?

查看:176
本文介绍了有什么方法可以检查Javascript变量的内存地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能在现代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.

推荐答案

来自这几乎是不可能的-Javascript的评估策略是始终使用按值调用,但是对于对象(包括数组),传递的值是对对象的引用,该对象不会被复制或克隆.如果您在函数中重新分配对象本身,则不会更改原始对象,但是如果您重新分配对象的属性之一,则会影响原始对象.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆