- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我很抱歉这个愚蠢的问题,但我对此感到困惑。
我一直在阅读 you don't know JS yet
书和书说
JS is most accurately portrayed as a compiled language.
最佳答案
更新:
当 JavaScript 在 1995-96 年首次出现时,Brendan Eich 创建了第一个 JS 引擎,称为 spider-monkey(仍在 Mozilla Firefox 中使用)。在这个时候,JavaScript 是在考虑浏览器的情况下创建的。这样任何来自服务器的文件都会被浏览器快速解释和显示。
Interpreter was a best choice to do so, since Interpretersexecutes code line by line and shows the results immediately.
const someCalculation = (num1, num2) => {
return num1 + num2;
};
for (let i = 0; i < 10000; i++) {
someCalculation(5, 6); // 11
}
它可以变得非常非常慢。
So the best option was introducing the Compiler,
const someCalculation = (num1, num2) => {
return num1 + num2;
};
for (let i = 0; i < 10000; i++) {
11; // And it will not call someCalculation again and again.
}
因为编译器不会为该循环中的每次传递重复翻译,所以从它生成的代码实际上更快。
And these sorts of edits that Compilers do are called Optimizations
This means that the Execution Speed of Javascript Code that we enteredinto the engine is going togradually improve because the Profiler and Compiler are constantlymaking updates and changes to our Byte code in order to be asefficient as possible. So Interpreter allows us to run the code rightaway while Profiler and Compiler allows us to optimize this code aswe are running.
When someone says Javascript is an interpreted language, yes there issome truth to it but it depends on the implementation. You can make animplementation of Javascript Engine that perhaps only compiles.Technically it all matters depending on the implementation.
关于JavaScript 是编译型语言还是解释型语言,还是两者兼而有之?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65697629/
我是一名优秀的程序员,十分优秀!