JS: Data Types & Variables
Learning Goals
- Review what you know about the primitive data types used in JavaScript
- Review how to create and use variables to store values
- Add variables to strings using concatenation and interpolation
Vocabulary
Data Type
A kind of data, defined by the values it can hold and the operations that can be done on itPrimitive type
Also known as asimple
data type. The primitives in Javascript that we will care about are Boolean, Undefined, Null, Number, String (BUNNS).Variable
A container for a value. The main building block for all programmingDeclare
Creating a new variable (distinct from assignment)Assignment
Assigning a value to a variableConcatenation
The binding of multiple strings together using the+
string operatorInterpolation
The process of injecting a variable directly into a string.
Part 1: Student Exploration
We will start this lesson with a BIG chunk of work time. You might be thinking - What! We haven’t learned anything yet! That’s not true! You already know some stuff about these concepts from Mod 0. Plus, you have problem solving skills (and googling skills 😉).
We want to give YOU a chance to dig into the code and explore before we all get together and talk about these concepts. It’s okay (and expected!) that some of this activity will be difficult on your own. We want you to get used to that feeling - not knowing all the answers - and start to enjoy the process of diving in and getting your hands dirty in the code!
Spend one hour working through this repl. As you’re working, write down the following things in your notes:
- Ah-ha moments/Key Points (for example:
A boolean is always a true or false value.
) - Questions (for example:
Do you ever use null or undefined on purpose?
)
If you get stuck…
- Reference this Intro to Data Types & Variables lesson
- Reference javascript MDN documentation. Use the search bar and Command+F to search for specific terms and concepts
- Google (for example:
null vs undefined javascript
) - Write down your question/what exactly you’re stuck on and move on. Then ask that question when we get on the zoom call!
After this hour, we will continue with the remainder of this lesson guided primarily by your questions.
Part 2: Class Discussion
Since this is your first mod 1 lesson, let’s go over some general classroom expectations:
- We prefer cameras ON, if possible. Being able to see each other helps us build relationships with one another. It also helps us teach you because we can read your facial/body language for cues on how the lesson is landing. That said, we want you to feel comfortable, so we understand if you need to have the camera off sometimes. Also, feel free to use a virtual background! Virtual backgrounds are a great way to give you some privacy and show off your personality!
- Ask questions. LOTS of questions! Each instructor will set up their preferred method for questions - whether it’s raising your hand, using the chat, or simply unmuting. It’s less important how you ask the question - we just care that you ask! No developer knows everything. One of the strongest skills a junior developer can bring to their team is their questions. Every single person on the call will learn from the questions you ask. Do it!
- We will always turn on Live Captioning. It’s totally up to you if you want to have the captions ON or OFF!
Questions
Asking questions is an essential part of being a developer. Take a few minutes right now to look through your notes from the last hour. What questions do you have about data types, variables, interpolation and concatenation? Everyone should have at least one question! Let’s add those questions to this jamboard.
Key Points
We just went through a lot of information. Let’s go over the most important things we need to know.
What are JavaScript’s primitive data types?
What do we need to know about each data type?
Whats the difference and use cases for undefined vs null?
Why do we need variables?
What are best practices for naming variables?
What is the difference between concatenation and interpolation?
What is type coercion?
What about let and const?
Post any questions you still have in your main cohort channel!