From the course: Computer Science Principles Lab: JavaScript
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Manage different variable types - JavaScript Tutorial
From the course: Computer Science Principles Lab: JavaScript
Manage different variable types
- [Instructor] As you work with JavaScript, you will create and manipulate variables of many different types. JavaScript is a dynamically-typed language, meaning that you don't need to define what type a variable can hold. It will adapt to hold whatever value is assigned to it. But that doesn't mean you're off the hook. You still need to manage your variable types, or otherwise, you might get some odd results in your program. Let's walk through some examples of how you can manipulate your variables and control their value types. First, let's create a number. Var myVariable equals five. We can then create a string that will contain the value of the variable, and then we can use the typeof statement to tell us what type of value it is. Var msg, for message, equals myVariable is equal to, and then we'll concatenate myVariable. Then we'll concatenate another string, and is a. Then we'll add the evaluation typeof myVariable. Then, we can send that to the console. Save the file, and open…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Capture input from the user9m 17s
-
(Locked)
Manage different variable types6m 43s
-
(Locked)
Create conditional tests12m 16s
-
(Locked)
Build compound conditional tests8m 42s
-
(Locked)
Use while loops4m 13s
-
(Locked)
Use for loops7m 35s
-
Create arrays to store groups of values3m 36s
-
(Locked)
Use loops with arrays3m 26s
-
(Locked)
Changing arrays3m
-
(Locked)
-