Site icon MiltonMarketing.com

Introduction to JavaScript – Data Types

Introduction to JavaScript - Review Types and Operators

Introduction to JavaScript - Review Types and Operators

Introduction to JavaScript – Data Types

Data types are the building blocks of all languages and essential pieces of any program.

Below are examples of four primitive data types that lay the foundation for all JavaScript programs. Primitive data types, as their name implies, are the simplest built-in forms of data.


console.log('New York City');
console.log(40.7);
console.log(true);
console.log(null);

In the example above, the computer logs each of the four primitive data types to the console. The types include:

Strings — Any grouping of keyboard characters (letters, spaces, numbers, or symbols) surrounded by single quotes (‘Hello’) or double quotes (“World!”). In the example above, ‘New York City’ is a string.

Numbers — Any number, including numbers with decimals: 4, 1516, .002, 23.42. In the example above, 40.7 is a number.

Booleans — Either true or false, with no quotations. In the example above, true is a boolean.

Null — Can only be null. It represents the absence of value.

Introduction to JavaScript – Data Types

 

Let’s review: a string is any grouping of words, a number’s a number, null is the absence of value, and a boolean is either true or false.



Related Links:

See JavaScript Glossary on Data-Type Strings

See JavaScript Glossary on Data-Type Numbers

See JavaScript Glossary on Data-Type Booleans

W3Schools.com JavaScript Data Types

Online JavaScript Compiler. Code on the go.

Exit mobile version