Introduction to JavaScript – Data Types

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');

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 JavaScript Data Types

Online JavaScript Compiler. Code on the go.

Connected through code, Choose Your Platform!

About the Author: Bernard Aybout

In the land of bytes and bits, a father of three sits, With a heart for tech and coding kits, in IT he never quits. At Magna's door, he took his stance, in Canada's wide expanse, At Karmax Heavy Stamping - Cosma's dance, he gave his career a chance. With a passion deep for teaching code, to the young minds he showed, The path where digital seeds are sowed, in critical thinking mode. But alas, not all was bright and fair, at Magna's lair, oh despair, Harassment, intimidation, a chilling air, made the workplace hard to bear. Management's maze and morale's dip, made our hero's spirit flip, In a demoralizing grip, his well-being began to slip. So he bid adieu to Magna's scene, from the division not so serene, Yet in tech, his interest keen, continues to inspire and convene.