Primitive Data Types and Values

Account Required

This free lesson is available if you sign in.
If you don't have an account, you can sign up for free.

Professional Modern JavaScript Lessons

1.Course Intro
free
⏱️ 1:13
2.Setup & Tooling
free
⏱️ 3:32
3.Debugger Statements and Breakpoints
free
⏱️ 2:17
4.Primitive Data Types and Values
free
⏱️ 3:06
5.JavaScript Variables - let and const
free
⏱️ 4:50
6.Comments in JavaScript
free
⏱️ 2:55
7.JavaScript Identifer Naming
free
⏱️ 2:52
8.Using TypeScript
free
⏱️ 4:26
9.JavaScript String Masterclass
free
⏱️ 9:29
10.JavaScript Boolean Type
⏱️ 6:45
11.Missing Guide to JavaScript Numbers
⏱️ 15:28
12.JavaScript Objects Demystified
⏱️ 13:33
13.Functions in JavaScript
⏱️ 20:25
14.JavaScript Arrays Masterclass
⏱️ 22:31
15.JavaScript If Else Statements and Best Practices
⏱️ 6:13
16.JavaScript Conditional Expressions
⏱️ 8:38
17.JavaScript Loose vs Strict Equality
⏱️ 4:02
18.Truthy vs Falsy in JavaScript
⏱️ 3:44
19.Concept of JavaScript Nullish and Unification
⏱️ 5:51
20.JavaScript Classes - Object Oriented Programming
⏱️ 10:30
21.JavaScript Error Handling and Exceptions
⏱️ 13:21
22.JavaScript Nullish Operators
⏱️ 5:48
23.JavaScript Switch Statement Masterclass
⏱️ 8:07
24.JavaScript For Loop Iteration Simplified
⏱️ 10:59
25.JSON Masterclass
⏱️ 7:59
26.JavaScript While and Do While Loops
⏱️ 2:52
27.JavaScript Date and Time Simplified
⏱️ 13:16
28.this in JavaScript
⏱️ 12:04
29.JavaScript Tagged Templates Masterclass
⏱️ 5:48
30.Promises in JavaScript
⏱️ 10:01
31.JavaScript Async Await Masterclass
⏱️ 9:00
32.JavaScript Symbols Demystified
⏱️ 7:25
33.JavaScript Iterators and Iterables
⏱️ 8:50
34.JavaScript Generators Simplified
⏱️ 9:17
35.JavaScript Prototype - The Secret Guide
⏱️ 11:21
36.JavaScript Set Builtin Data Structure
⏱️ 9:52
37.JavaScript Map Builtin - HashMap Magic
⏱️ 10:38
38.JavaScript Deferred Promise Pattern - withResolvers
⏱️ 3:35
39.Cloning and Deep Copying in JavaScript
⏱️ 3:14
40.JavaScript Async Await Sequencing and Execution Masterclass
⏱️ 10:31
41.JavaScript Memory Management Masterclass
⏱️ 5:26
42.JavaScript WeakMap Demystified
⏱️ 8:58
43.JavaScript bigint Masterclass
⏱️ 5:35
44.JavaScript WeakSet Explained with Examples
⏱️ 7:47
45.JavaScript Regular Expressions Masterclass
⏱️ 17:54
46.JavaScript Weak References Demystified
⏱️ 5:29
47.JavaScript Memory Leaks Demonstrations and Fixes
⏱️ 6:01
48.Semicolon Free Coding in JavaScript
⏱️ 3:46
49.JavaScript Modules Masterclass
⏱️ 11:36

Primitive Data Types and Values

Sign in to access this content

You must sign in to access this content.
If you don't have an account you can sign up for free!

Strings

console.log('Hello world'); // Hello world
console.log("Hello world"); // Hello world
console.log("Hello 'world'"); // Hello 'world'
console.log('Hello "world"'); // Hello "world"
console.log('\'Hello\' "world"'); // 'Hello' "world"
console.log("'Hello' \"world\""); // 'Hello' "world"

Number

console.log(1337);
console.log(3.14);
console.log(-1000);

Big Int

console.log(100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000n);

Booleans

console.log(true);
console.log(false);

Absent Values

Note: We discuss the difference between the null and undefined more in later lessons.

console.log(undefined);
console.log(null);

Symbol

console.log(Symbol('magic')); // Symbol(magic)
javascript
typescript
react
playwright

Enjoy free content straight from your inbox 💌

No spam, unsubscribe at any time.

Transcript

00:00

JavaScript only has a few primitive data types, and we've already used one primitive, which is the string in our simple log messages, and we will uncover the others in this lesson. Now, all the strings that we have created up to this point, we have used the single quote character. We can actually create strings within JavaScript using the double code as well. And at runtime, there is no difference between these two. It's simply a matter of preference. I personally prefer to use single coats wherever possible. Now, if the string that you're going to write contains a single coat on the inside, it is recommended that you use a double coat on the outside. And similarly,

00:35

if you have a string that contains a double coat on the inside, then we recommend that you use a single coat on the outside. Now, you can actually put a single coat inside a single coat by using an escape character, which is backslash within JavaScript, and then using the single coat that way. And similarly, within a double coded string, you can place a double coat by using backslash double coat as we have done in this example. Now, another primitive data type that exists within JavaScript is the number data type. And this is actually always a 64 bit floating point. So of course we can use it for intes,

01:08

but the same data type supports fractions as well. And this is actually a signed value, which means that we can have positive as well as negative numbers within JavaScript. Now, because the number data type is a 64 bit value, there is an upper limit on the integers that we can store safely within this. But if you want to store integers, which are as large as we want, for example, a Google value, we can do that with a big inter type that is provided by JavaScript. To present a big value within JavaScript, we simply write our integer and then add the suffix of the character N. Now, of course, because it doesn't have a fixed precision,

01:44

it is not going to perform as nicely as the number data type. So only use it if you really need to. A key to type within JavaScript to which plays a critical role in conditional logic is the bullion datatype. And this only has two possible literal values, which are either the literal true or the literal false. Undefined within JavaScript is a special value and a datatype, which is the value that the JavaScript runtime will return when a variable hasn't been initialized. Another primitive value within JavaScript is the value null, and this is a value that JavaScript developers will use to denote a value that isn't present. For example,

02:19

if you ask a function for a user profile but the user isn't currently logged in, we can instead choose to return null to denote that we have no user to return. We will discuss the differences between ANU and Undefined and how we can simplify these concepts in much greater detail later on. And finally, we have a symbol, which is a TE type that you are very unlikely to use yourself, but exist as a part of core JavaScript to internally make things like it ripples possible. The symbol type allows these internal implementations from leaking out to our normal code base. And that's it.

02:53

This is a nice tea sheet of all of the primitives that exist within JavaScript. Now that we know what we have to look forward to, we will discuss lots of details of all of these primitives in their own dedicated lessons.

Professional Modern JavaScript

Professional Modern JavaScript

1.Course Intro
free
⏱️ 1:13
2.Setup & Tooling
free
⏱️ 3:32
3.Debugger Statements and Breakpoints
free
⏱️ 2:17
4.Primitive Data Types and Values
free
⏱️ 3:06
5.JavaScript Variables - let and const
free
⏱️ 4:50
6.Comments in JavaScript
free
⏱️ 2:55
7.JavaScript Identifer Naming
free
⏱️ 2:52
8.Using TypeScript
free
⏱️ 4:26
9.JavaScript String Masterclass
free
⏱️ 9:29
10.JavaScript Boolean Type
⏱️ 6:45
11.Missing Guide to JavaScript Numbers
⏱️ 15:28
12.JavaScript Objects Demystified
⏱️ 13:33
13.Functions in JavaScript
⏱️ 20:25
14.JavaScript Arrays Masterclass
⏱️ 22:31
15.JavaScript If Else Statements and Best Practices
⏱️ 6:13
16.JavaScript Conditional Expressions
⏱️ 8:38
17.JavaScript Loose vs Strict Equality
⏱️ 4:02
18.Truthy vs Falsy in JavaScript
⏱️ 3:44
19.Concept of JavaScript Nullish and Unification
⏱️ 5:51
20.JavaScript Classes - Object Oriented Programming
⏱️ 10:30
21.JavaScript Error Handling and Exceptions
⏱️ 13:21
22.JavaScript Nullish Operators
⏱️ 5:48
23.JavaScript Switch Statement Masterclass
⏱️ 8:07
24.JavaScript For Loop Iteration Simplified
⏱️ 10:59
25.JSON Masterclass
⏱️ 7:59
26.JavaScript While and Do While Loops
⏱️ 2:52
27.JavaScript Date and Time Simplified
⏱️ 13:16
28.this in JavaScript
⏱️ 12:04
29.JavaScript Tagged Templates Masterclass
⏱️ 5:48
30.Promises in JavaScript
⏱️ 10:01
31.JavaScript Async Await Masterclass
⏱️ 9:00
32.JavaScript Symbols Demystified
⏱️ 7:25
33.JavaScript Iterators and Iterables
⏱️ 8:50
34.JavaScript Generators Simplified
⏱️ 9:17
35.JavaScript Prototype - The Secret Guide
⏱️ 11:21
36.JavaScript Set Builtin Data Structure
⏱️ 9:52
37.JavaScript Map Builtin - HashMap Magic
⏱️ 10:38
38.JavaScript Deferred Promise Pattern - withResolvers
⏱️ 3:35
39.Cloning and Deep Copying in JavaScript
⏱️ 3:14
40.JavaScript Async Await Sequencing and Execution Masterclass
⏱️ 10:31
41.JavaScript Memory Management Masterclass
⏱️ 5:26
42.JavaScript WeakMap Demystified
⏱️ 8:58
43.JavaScript bigint Masterclass
⏱️ 5:35
44.JavaScript WeakSet Explained with Examples
⏱️ 7:47
45.JavaScript Regular Expressions Masterclass
⏱️ 17:54
46.JavaScript Weak References Demystified
⏱️ 5:29
47.JavaScript Memory Leaks Demonstrations and Fixes
⏱️ 6:01
48.Semicolon Free Coding in JavaScript
⏱️ 3:46
49.JavaScript Modules Masterclass
⏱️ 11:36