One thing we should clear up right now:
It has no relationship to Java. They are completely separate languages that happen to have similar sounding names.
We reviewed HTML and CSS, and I'm going to assume everyone is familiar with what a web browser is, let's pause for a moment and discuss what we know about web browsers.
Static vs Dynamic
You have probably heard these terms before, what do they mean to you?
Static and dynamic are important terms to keep in mind when talking about programming. Some of the work we do in class will be static, meaning there is no change over time.
Ultimately our projects will include animation and interaction, making them dynamic. The content will change given user input over time.
|Command + Alt + J
|Control + Shift + J
If you're on another browser you can either Google how to open the console or switch to Chrome.
Type an expression into the console and then hit R
(Enter) to see it be evaluated.
2 + 2
The console is used mostly for debugging, which is a process that developers do when something in their code is not doing what they want it to do. The console is useful for evaluating statements and functions and sending messages from the code to the console, where the developer can see it, but the user typically would not.
We'll talk more about debugging in a later lesson.
Let's look at some more arithmetic expressions.
1 - 1
2 * 5
12 / 4
Expressions can also be grouped using parentheses.
2 + 2 * 5
(2 + 2) * 5
Uncaught SyntaxError: Unexpected number
Something that we often need to do in a program is make a decision based on different values. To do this, we can use boolean expressions, which evaluate whether a statement is
== operator is used to evaluate a boolean statement.
1 == 1
2 + 2 == 4
2 + 2 == 5
We can also compare the relative values of numbers using
<, less than, and
>, greater than.
3 < 4
99 > 100
We can also use
<=, less than or equal to and
>=, greater than or equal to.
0 <= 1
1 <= 1
0 >= 1
1 >= 0
Integers and Floats
The numbers we have been using so far are all whole numbers, or integers, numbers that do not have a decimal point value.
3 / 4
The third primitive data type is the
string. A string is a series of characters. It's kind of like a word or a sentence.
"I am a string."
typeof "I'm a string"
We'll talk more about strings and other data types in later lessons.
Environment objects and properties