What is JavaScript?
JavaScript is a scripting language and it supports client side scripting.
JavaScript is a lightweight, interpreted programming language with object-oriented
capabilities
that allows you to build interactivity into otherwise static HTML pages.
Dynamic typing
JavaScript is a loosely typed or a dynamic language. That means you don't have to
declare the type of a variable ahead of time. The type will get determined
automatically while the program is being processed. That also means that you can
have the same variable as different types:
var foo = 42; // foo is now a Number
var foo = "bar"; // foo is now a String
var foo = true; // foo is now a Boolean
JavaScript support all the primitive data types like
Six data types that are primitives:
1.
2.
3.
4.
5.
6.
7.
Boolean
Null
Undefined
Number
String
Symbol (new in ECMAScript 6)
and Object
Boolean type:Boolean represents a logical entity and can have two values: true, and false.
Null type:The Null type has exactly one value: null.
Undefined type:A variable that has not been assigned a value has the value undefined.
Var is the keyword used in JavaScript for declaring the
variable. The value to the variable can be assigned at the time of declaring the
variable or at any point of time in the program. We need not declare data type for
the variables. The variables in JavaScript are flexible and adjust itself to the type of
data assigned to it.
A number of variables can also be declared with a var keyword separated by
comma.
E.g.: var name, age;
Variables in JavaScript are case sensitive. Variable name and Name are two different
variables
whereas name and Name are the same variables in ABAP.