Prev Page Next Page
Top

JavaScript Data Types

➢In programming, data types is an important concept.
➢To be able to operate on variables, it is important to know something about the type.
➢Without data types, a computer cannot safely solve this:

EXAMPLE:

let x = 16 + "Volvo";

➢Does it make any sense to add "Volvo" to sixteen? Will it produce an error or will it produce a result?
➢JavaScript will treat the example above as:

EXAMPLE:

let x = "16" + "Volvo";

JavaScript Types are Dynamic

➢JavaScript has dynamic types. This means that the same variable can be used to hold different data types:

EXAMPLE:

let x;
// Now x is undefined let x = 10; // Now x is a Number
let x = "Moksha"; // Now x is a String

Prev Page Next Page





FEEDBACK

Rating


Message