TypeScript Fundamentals Primitive Types
This course has been updated! We now recommend you take the TypeScript Fundamentals, v3 course.
Transcript from the "Primitive Types" Lesson
[00:00:41] We'll learn a little bit about specific uses of symbol later. Just know that it is something where the name of the symbol is equal to its value. So, think of it like you can kinda treat them like strings. Imagine if it's like a string where variable name in this string the contents of the string had to match, right.
>> Mike North: Everything else in the language extends from Object, an array extends from Object, right. And that Object, we'll see later that that is sort of the basis for mutable values, everything else is immutable. So when necessary these primitive types are wrapped in a more rich object. And you'll recognize these richer objects because they start with a capital letter instead of the lower case letter.
[00:02:05] The output we'll end up seeing is this, right, so clearly these are not exactly the same. Now if we were to compare these two, they would be different in this case. So what we're gonna do is we can look at the fact that it's, that this idea of Carries over to Booleans as well.
>> Mike North: I showed this to you so you'd know the difference between lowercase s string, and uppercase S string. And the fact that we can say these have no methods, but they're sort of promoted automatically into things that have methods, like as soon as you need them. So most of the time this doesn't matter to us, but you just need to know that the primitive types, like a string, a number, a Boolean, these values are mutable.
[00:02:56] Meaning when we split a string, we are not mutating that string in place, we're creating new strings, right.
>> Mike North: Never, well I'm not gonna say never but it is nearly always incorrect to refer to the boxed variant of the primitive types. So when we start getting into things like type annotations, just make sure it gonna look for a lowercase s string.
[00:03:26] And call me out if you see something on the slides. I hope that I have wrestled the auto-capitalization of QNote back into submission. But just know the differences between those.