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

Make a JS object go from typeof="object" to typeof="undefined"

本文关键字:typeof 变为 undefined JS object 对象      更新时间:2023-09-26

肯定很容易,但我找不到解决方案。我有一个对象,我现在想要未定义。如何将类型更改为未定义?谢谢!

凯尔

你不能使对象本身undefined,但你可以使引用它的变量undefined

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

您应该可以使用关键字"delete"将其删除。然后它的引用将是未定义的。

delete myObj;