The data type in javascript describes the basic elements that can be used within that language. JavaScript supports four primitive data types:
Data types in JavaScript:
1. Numbers- are values that can be processed and calculated. You do not enclose them in quotation marks. The numbers can be either positive or negative.
2. Strings- are a series of letters and numbers enclosed in quotation marks. JavaScript uses that string literally; it doesn't process it. You'll use string for the text you want to be displayed or values you want to be passed along.
3. Boolean (true/ false) - lets you evaluate whether a condition meets or doesn't meet specified criteria.
4. Null- is an empty value. Null is not the same as 0--0 is a real, calculable number, whereas null is the absence of any value.
Number:
The numbers and can be integers (such as 2, 22 & 2000) or floating point values (such as 23.42, -56.01, & 2e45).
We can represent an integer in one of the following three ways:
Decimal: The usual numbers which are having the base 10 are the decimal numbers.
Octal: octal literals begin with a leading zero, and consist of digits from 0 through 7. The following are all valid actual literals:
00 0777 024513600
Hexadecimal: hexadecimal literals begin with a leading 0x, and they consist of digits from 0 through 9 and letter A through F. The following are all valid hexadecimal literals:
0x0 0xF8f00 0x1a3C5e7
String:
String means a set of characters. In javascript, strings are enclosed in a pair of single quotes or double-quotes. The value of the can even contain space and maybe totally made from digits.
“Chris” “Chris bates” “234.56”
Boolean:
Boolean variables hold the values true and false. These are used to hold the result of conditional tests.
Null:
It consists of a single value, null, which identifies a null, empty, or nonexistent reference. Its null value is common in all JavaScript types.
I hope you guys understand what is javascript datatype and its primitive type. If you find any mistake or having any queries then please comment down below. Thank you for reading.
No comments:
Post a Comment