我在这里

🏠 HOME 🗂️ DOCS 🔗 LINK 👴🏻 ABOUT
https://qiniu.sukoshi.xyz/src/images/cover/cover-06.jpg

JavaScript中的GC

2019-12-19 10:52

  • 笔记
  • js
const f = function () {
  let v = "string";

  let c = function () {
    v = document.createElement("div");
  }

  let p = function () {
    console.log(v);
  }

  return { c, p }
}

f().c();

f().p(); // string

在调用f().c()以后,f没有被其他资源,被立即释放,即f().c()以后被GC;

如何才能不被自动GC:

let o = f();

o.p(); // string

o.c();

o.p(); // <div></div>

如何手动释放:

o = null;

o = f();

o.p(); // string

五十音补充笔记

2020-01-09 16:55

关于removeEventListener里使用里bind不生效解决办法

2019-12-04 19:13

Sukoshi

Sukoshi

不觉得鹿角即可爱又有攻击性吗(

Related Posts

  • 在CSS变量中使用SCSS变量无效
  • CSS使用字体新姿势 unicode-range用法与使用场景
  • ES6中的模块
  • zsh和oh-my-zsh常用配置和命令
  • 日语五十音
  • 五十音补充笔记

Categories

  • 笔记 20
  • 归档记录 9
  • 碎碎念 8
  • QAQ 7
  • doc 6
  • mv 3
show all

Tags

摄影 日常 js 浪 mongodb 日记 碎碎念 canvas cos css git github
show all

© 2022 Sukoshi.

蜀ICP备15014309号

Powered by Hugo Theme - kagome

🌞 light 🌛 dark 🤖️ auto