Page 124 - CITS - Computer Software Application -TT
P. 124
COMPUTER SOFTWARE APPLICATION - CITS
uses fewer resources than other languages. For example, NodeJs, a variation of JavaScript not only performs
faster computations but also uses fewer resources than its counterparts such as Dart or Java.
Additionally, when compared with other programming languages, it has fewer in-built libraries or frameworks,
contributing as another reason for it being lightweight. However, this brings a drawback in that we need to
incorporate external libraries and frameworks.
Is JavaScript Compiled or Interpreted or both ?
JavaScript is both compiled and interpreted. In the earlier versions of JavaScript, it used only the interpreter that
executed code line by line and shows the result immediately. But with time the performance became an issue as
interpretation is quite slow. Therefore, in the newer versions of JS, probably after the V8, the JIT compiler was
also incorporated to optimize the execution and display the result more quickly. This JIT compiler generates a
bytecode that is relatively easier to code. This bytecode is a set of highly optimized instructions.
The V8 engine initially uses an interpreter, to interpret the code. On further executions, the V8 engine finds
patterns such as frequently executed functions, and frequently used variables, and compiles them to improve
performance.
JavaScript Syntax, Variables, Operators and Expression
JavaScript Syntax
JavaScript syntax is the set of rules, how JavaScript programs are constructed:
// How to create variables:
var x;
let y;
// How to use variables:
x = 5;
y = 6;
let z = x + y;
JavaScript Values
The JavaScript syntax defines two types of values:
• Fixed values
• Variable values
Fixed values are called Literals.
Variable values are called Variables.
JavaScript Literals
The two most important syntax rules for fixed values are:
1 Numbers are written with or without decimals:
10.50
1001
2 Strings are text, written within double or single quotes:
“John Doe”
‘John Doe’
JavaScript Variables
In a programming language, variables are used to store data values.
111
CITS : IT&ITES - Computer Software Application - Lesson 37 - 46