delete do else enum export extends false finally for
function if implements import interface in instanceof let
new package private protected public return static super
switch this throw true try typeof var void while with yield
break
can be used to break out of the loop continue
jumps out of the body to continue to the next iteration counter *= 1
, counter++
,counter--
switch (prompt("What is the weather like?")) {
case "rainy":
console.log("Remember to bring an umbrella.");
break;
case "sunny":
console.log("Dress lightly.");
case "cloudy":
console.log("Go outside.");
break;
default:
console.log("Unknown weather type!");
break;
}
typeof
is also an operator (unary, bc it only takes one number) `${something}`
)console.log("Aardvark" < "Zoroaster") //true
)null || "user" // user
, "Agnes" || "user" // Agnes
)absence of meaningful value (1. null; 2. undefined: yet to yield some value)
0, NaN, "" count as false, all others as true
when null or undefined occurs on either side of the operator, it produces true only if both sides are one of null or undefined. which is useful to test whether a value has a real value
console.log(null == undefined);
// → true
console.log(null == 0);
// → false
Used version of JS: 2017
Like human languages, computer languages allow words and phrases to be combined in new ways, making it possible to express ever new concepts.
Mindset:
When you are struggling to follow the book, do not jump to any conclusions about your own capabilities. You are fine—you just need to keep at it. Take a break, reread some material, and make sure you read and understand the example programs and exercises. Learning is hard work, but everything you learn is yours and will make subsequent learning easier.
On programming complexity:
Keeping programs under control is the main problem of programming. When a program works, it is beautiful. The art of programming is the skill of controlling complexity. The great program is subdued—made simple in its complexity.
Some programmers believe that this complexity is best managed by using only a small set of well-understood techniques in their programs. They have composed strict rules (“best practices”) prescribing the form programs should have and carefully stay within their safe little zone.
This is not only boring, it is ineffective. New problems often require new solutions. The field of programming is young and still developing rapidly, and it is varied enough to have room for wildly different approaches. There are many terrible mistakes to make in program design, and you should go ahead and make them so that you understand them. A sense of what a good program looks like is developed in practice, not learned from a list of rules.