part scope
function scope
- variables declared inside a function cannot be accessed externally
- after the funnction is executed,it will be cleared
block scope
- package code blocks with
{}
global scope
-
<script>
.js
scope chain
Essentially,if is asearch machanism for underlying variables
- when the function is executed, it will ifrst search for the current scope variable
- if the current function cannot be found,the parent will be searched step by step
garbage recycling mechanism
Track the number of times it is referenced,add 1 for every reference,subtract 1 for every reference,and release memory if it is 0
disadvantage
if nested refernces are used,they cannot be released
mark clearing method
Scheduled scanning will mark objects that cannot be reached from the root as unusable, and then recycle them