脚本语言中的代码的技术术语是什么,它不是任何函数的一部分,并且在导入脚本时首先执行?
例如,在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.
通常,在全局范围内运行的代码简称为“在全局范围内运行的代码”.