Reading the first chapter of “You Don’t Know JS: Up & Going” has been very helpful for me in gaining more exposure to the basic components of JavaScript. Here are some of the notes I took while reading this chapter:
Statements: a group or words, numbers, and operators that perform a specific task. ex: a = b * 2;
4 expressions in statements:
2 is a literal value expression b is a variable expression, which means to retrieve its current value b * 2 is an arithmetic expression, which means to do the multiplication a = b * 2 is an assignment expression, which means to assign the result of the b * 2 expression to the variable a (more assignments later)
Variables: symbolic placeholders that hold values. ex: a and b
operators: perform actions with the values and variables such as assignment and mathematical multiplication. ex: = and *
output using console.log or alert will run the previous snippets of code.
Input Receiving information from the user. Prompt function. ex: age = prompt( “Please tell me your age:”); console.log( age);
Different representations for values are called types. Javascript has built-in types called primitive values. ex: math—> you want a number print a value on the screen —> string making a decision in your program —> boolean (true or false)
Values included directly in the source code are called literals. String literals are surrounded by quotes (“” or ‘ ‘) number and boolean are presented without.
if you want to print a number on the screen, you need to convert the value to a string. Javascript calls the conversion coercion.
JavaScript uses dynamic typing, a variable can hold values of any type without any type enforcement.
State is tracking the changes to values as your program runs.
Assign functions to calls on values, like the book talks about assigning a function that calculates the tax.) In JavaScript, a blocks wrap one or more statements inside a curly-brace pair { .. } Typically, blocks are attached to some other control statement, such as an ‘if’ statement.
Loops return a function so long as the condition holds. We are asking it to repeat it’s function until it has executed the task within its assigned parameters.
A scope inside of another scope can access ALL of the variables outside of it. Comment your steps so you can see what the different steps mean. I don’t know why I didn’t think of this one but this piece of advice will be so helpful for me moving forward. With the a better understanding of what all the components do now, I think commenting through all the steps will help me to not lose track of what I am working on! This also made reading through the examples vastly easier for me to grasp then staring at a wall of coding.
It was very helpful for me to see multiple examples of loops being written out and I tried my best to follow along in my console in snippets. I have been struggling with loops and after reading through ‘for’ ‘while’ and ‘do…while’ loops I am feeling more comfortable with how they operate. Overall I think this has been a little more helpful for me then my initial experience with “Eloquent JavaScript”, if only because there are more examples for me to work on and I need the practice.