简体   繁体   English

使JS对象从typeof =“ object”变为typeof =“ undefined”

[英]Make a JS object go from typeof=“object” to typeof=“undefined”

this must be easy but I can't find the solution. 这一定很容易,但是我找不到解决方案。 I have an object that I want to now be undefined. 我有一个我现在想不确定的对象。 How can I change the typeof to undefined? 如何将typeof更改为undefined? Thanks! 谢谢!

Kyle 凯尔

You can't make the object itself undefined , but you can make the variable that references it undefined . 您不能使对象本身undefined ,但可以使引用它的变量undefined

  var myObj = { ... };
  myObj = undefined;

You should be able to just delete it using keyword 'delete'. 您应该能够使用关键字“ delete”将其删除。 Then its reference will be undefined. 然后其引用将是不确定的。

delete myObj;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM