Javascript is a scripting language. So you don't need a compilation process.
The script language features are described in this way.
It is executed by analyzing text in real time without going through the compilation process. (Some scripting languages support simple compilation) If there is a grammatical error in the code, it is found at the time of execution. (In recent years, it is often found in the parsing stage before execution.)
When JavaScript is run in a browser, it is interpreted one line at a time by the interpreter included in the browser.
You'll understand if you look at the following example that it runs one line at a time. If you look at the JavaScript code below, there is a grammar error in the else statement. But if you press "Run" underneath the code, it'll run without a problem.
var a = 10;
if(a > 0){
console.log ("It runs well."")
}
else{
//Even if you write down a line like this that doesn't make sense, it works well.
//This is because the interpreter passes unread by an if statement.
wesdhfoawefoiawesdfp
}
However, compilation languages such as c are not allowed because they run after compiling the entire code. Press the Run code button below to run the code below. An error occurs during the compilation process, even if the else statement cannot be executed.
#include <stdio.h>
int main(){
int a = 10;
if(a > 0){
printf ("Will it run well?"");
}
else{
//c results in a compilation error.
wesdhfoawefoiawesdfp
}
return 0;
}
In this way, the compilation language and the script language behave differently. JavaScript, a scripting language, is not compiled into other languages, and the browser reads one line at a time and executes it.
© 2024 OneMinuteCode. All rights reserved.