number for numbers of any kind: integer or floating-point, integers are limited by ±(253-1).
bigint for integer numbers of arbitrary length.
string for strings. A string may have zero or more characters, there’s no separate single-character type.
boolean for true/false.
null for unknown values – a standalone type that has a single value null.
undefined for unassigned values – a standalone type that has a single value undefined.
symbol for unique identifiers.
And one non-primitive data type:
object for more complex data structures.let age = prompt('How old are you?', 100);
alert(`You are ${age} years old!`); // You are 100 years old!The function confirm shows a modal window with a question and two buttons: OK and Cancel.
The result is true if OK is pressed and false otherwise.
Not unic
The result is true if OK is pressed and false otherwise.
Not unic
let isBoss = confirm("Are you the boss?");
alert( isBoss ); // true if OK is pressedlet year = prompt('In which year was the ECMAScript-2015 specification published?', '');
if (year < 2015) {
alert( 'Too early...' );
} else if (year > 2015) {
alert( 'Too late' );
} else {
alert( 'Exactly!' );
}Addition +,
Subtraction -,
Multiplication *,
Division /,
Remainder %,
Exponentiation **.
alert( 6 - '2' ); // 4, converts '2' to a number
alert( '6' / '2' ); // 3, converts both operands to numbers
Katta/kichik: a > b, a < b.
Katta/kichik yoki teng: a >= b, a <= b.
Teng: a == b, esda tutingki, qo'shaloq tenglik belgisi == tenglik testini bildiradi, bitta a = b esa topshiriqni bildiradi.
Teng emas: matematikada yozuv ≠, lekin JavaScript-da u != b shaklida yozilgan.
Katta/kichik: a > b, a < b.
Katta/kichik yoki teng: a >= b, a <= b.
Teng: a == b, esda tutingki, qo'shaloq tenglik belgisi == tenglik testini bildiradi, bitta a = b esa topshiriqni bildiradi.
Teng emas: matematikada yozuv ≠ , lekin JavaScript-da u != b shaklida yozilgan.
Katta/kichik yoki teng: a >= b, a <= b.
Teng: a == b, esda tutingki, qo'shaloq tenglik belgisi == tenglik testini bildiradi, bitta a = b esa topshiriqni bildiradi.
Teng emas: matematikada yozuv ≠ , lekin JavaScript-da u != b shaklida yozilgan.
let year = prompt('In which year was the ECMAScript-2015 specification published?', '');
if (year < 2015) {
alert( 'Too early...' );
} else if (year > 2015) {
alert( 'Too late' );
} else {
alert( 'Exactly!' );
}