Welcome back to Learn to Code and JavaScript.
Next, we're going to talk about primitive data types.
So what are the primitive data types?
So one is called undefined and we'll see an example that it just means something has no definition.
Bullion is a data type that can be true or false.
Numbers can be whole numbers or decimal numbers.
And they have a certain range.
Strings are set of zero more characters like Hello, World is a strange.
Big event is an arbitrary precision, no, you using things like cryptography and things like that where
you need really, really long numbers.
And several produces a unique value of these we're only going to be focusing on undefined billion number
and string.
So literal data versus variables, a literal value like the number two, can only be used once.
So you put it in the program, you say Castletown log too, and that too, you can repeat it, but it's
a different version of that to so undefined has a value of undefined boolean.
A literal value could look like true numbers.
It could look at one zero twenty two point five six seven.
And if you haven't seen this before, it looks so different to point to five, six, seven E one.
The E is an exponential notation or scientific notation, which means times 10 to the first.
So that number and twenty two point five, six, seven are equivalent.
Strength, we've seen some of these before, however, with Dovecote, good Bárbara with single quotes.
Twelve point twenty two in quotes is a string, not a number, true in quotes is a string, not a no.
A variable stores value could be used again.
And for primitive, dated variables are immutable.
And what this means is that if you cannot really be changed, you just get a new copy of it.
Variables are stored in computer memory is one or more bytes and a bite has eight bits of zeros or ones.
So, for example, a number is two bites, I'm sorry.
Number is, I think eight bites and there eight bites of zeros and ones, a character and a string of
two bites.
That has a representation of that character.
Variable scope variables are defined in a scope, and we talk about the scope of a function in the previous
structure, which is the space between curly braces.
We want to avoid is global scope because then you can have like side effects and we'll take a look at
that.
Some keywords, VA, which is an old way to declare variables and JavaScript, but it declares it in
global scope, don't use it.
You'll see it being used, but you should not use it because it's been replaced by LET, and that lets
you define a new variable or contract which allows you to declare a variable that cannot be reassigned,
a new value.
JavaScript uses dynamic variable definition so a variable can have different types, so you could say
let X equals three.
That's the way to define it, variable X, that's the number that has the value of three.
But you can turn right around and say X equals hello.
As a stray.
So now X is a string, not a no.
And then you can say X equals true.
So some information about scope and you've also seen this word at the top, secret mode you stripped.
And look at a definition of that, but what it does is prevents use of undeclared variables.
And then scope, as I mentioned, is the boundaries of the left, curly brace and right curly brace
for variables are known and defined.
So we'll look at a couple of examples of that.