脚本语言中不属于任何函数且在导入脚本时首先执行的代码的技术术语是什么?
例如,在python中:
import anything
#what is the technical name for this code?
a = 1
doABackFlip()
def myFunction():
#Not this code since it is part of a function
b = 2
runSomething()
class myClass():
#This is in a class so not this code either
在 JavaScript 中:
<script>
//What is the technical name of this code?
a = 1
doABarrelRoll()
function myFunction() {
//Not this stuff. Part of a function again
doSomethingCool()
}
</script>
我正在专门为这段代码寻找一个或两个单词的术语。如果它是一个常用的描述符或更好的描述符,最好是 60 年代一些学术论文中创造的东西。
最佳答案
我不确定在函数外部运行的代码是否有特定的名称,但它们运行的“空间”在各种语言中确实有一个通用名称:它被称为 global scope .
通常,在全局范围内运行的代码简称为“在全局范围内运行的代码”。
关于javascript - 代码的技术名称不属于任何功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16802306/