JavaScript: The Web Warrior Series
Rate it:
Kindle Notes & Highlights
Read between October 12, 2018 - January 19, 2019
hypertext linking,
Comments are lines of code that are not processed by browsers, which you use to add notes about your code.
Bob Downs
Comments definition
A line comment occupies only a single line or part of a line.
Bob Downs
Line Comment definition
To create a line comment, you add two slashes ( // ) before the text you want to use as a comment. The // characters instruct JavaScript interpreters to ignore all text following the slashes on the same line. You can place a line c...
This highlight has been truncated due to consecutive passage length restrictions.
Bob Downs
Line Comment how to
Block comments hide multiple lin...
This highlight has been truncated due to consecutive passage length restrictions.
Bob Downs
Block Comments definition
You create a block comment by adding /* to the first line that you want included in the block, and you close a comment block by typing */ after the last character in the block. Any text or lines between the opening /* characters and the closing */ characters are ignored by JavaScript interpreters. A JavaScript block comment uses the same syntax as ...
This highlight has been truncated due to consecutive passage length restrictions.
Bob Downs
Block Comments how to
. JavaScript code in an HTML document goes within which HTML element?
Bob Downs
script
. Why should you end every JavaScript statement with a semicolon?
Bob Downs
Even though the statements do not end in semicolons, the preceding script is legal. However, that’s not the end of the story. Programmers often adopt conventions in their code that make the code easier for themselves or other programmers to read in a text editor. In the case of semicolons, it is considered good JavaScript programming practice to end every statement with a semicolon. The semicolon serves to identify the end of each statement, making it easier for a programmer to read his or her own code (and for other programmers to read the code later on). In addition, a JavaScript parser must perform work on a script without semicolons to determine where each statement ends, which can slow down a web page and detract from the user experience. For these reasons, you should be sure to end all of your JavaScript statements with semicolons.
The values a program stores in computer memory are commonly...
This highlight has been truncated due to consecutive passage length restrictions.
Bob Downs
Variables definition
The name you assign to a variable is called an identifier.
Bob Downs
Identifier definition
Identifiers must begin with an uppercase or lowercase ASCII letter, dollar sign ($), or underscore ( _ ). You can use numbers in an identifier but not as the first character. You cannot include spaces in an identifier. You cannot use reserved words for identifiers.
Bob Downs
Variable name rules and conventions
Reserved words (also called keywords) are special words that are part of the JavaS...
This highlight has been truncated due to consecutive passage length restrictions.
Bob Downs
Reserved words (aka keywords) definition
camel case, which is a method of capitalization that uses a lowercase letter for the first letter of the first word in a variable name, with subsequent words starting with an initial cap, as in myVariableName.
Bob Downs
camel case definition
Using the var keyword to create a variable is called declaring the variable.
Bob Downs
declaring definition
When you declare a variable, you can also assign a specific value to, or initialize, the variable by adding an equal sign ( = ) after the variable name, followed by the value you’re assigning to the variable, as follows: var variable_name = value;
Bob Downs
initialize definition
The equal sign in the preceding statement is called an assignment operator because it assigns the value on the right side of the expression to the vari...
This highlight has been truncated due to consecutive passage length restrictions.
Bob Downs
assignment operator definition (referring to "var variable_name = value;")
You are not required to use the var keyword to declare a variable. However, omission of the var keyword affects where a variable can be used in a script. In addition, declaring variables without the var keyword can make it more challenging later to identify where in a program a variable is first declared. For these reasons, it is good prog...
This highlight has been truncated due to consecutive passage length restrictions.
Bob Downs
var keyword required or not
An expression is a literal value or variable, or a combination of literal values, variables, operators, and other expressions, that can be evaluated by a JavaScript interpreter to produce a result.
Bob Downs
expression definition
Operands are variables and literals contained in an expression.
Bob Downs
operands definition
A literal is a value such as a literal stri...
This highlight has been truncated due to consecutive passage length restrictions.
Bob Downs
literal definition
Operators, such as the addition operator ( + ) and multiplication operator ( * ), are symbols used in expre...
This highlight has been truncated due to consecutive passage length restrictions.
Bob Downs
operators definition
An event is a specific circumstance (such as an action performed by a user or an action performed by the browser) that is monitored by JavaScript and that your script can respond
Bob Downs
event definition (1st part, anyway)
Using the Array Object Arrays are represented in JavaScript by the Array object. The Array object contains a special constructor named Array() that provides another way to create an array. A constructor is a special type of function that is used as the basis for creating reference variables (that is, variables whose data type is the reference data type). You can create new arrays with the Array() constructor by using the keyword new and the name of the Array() constructor with the following syntax: var arrayName = new Array(number of elements); Within the parentheses of the ...more
Bob Downs
Using the Array Object
Unlike getElementById(), which uses the singular version of “element,” the word “elements” in getElementsByTagName() has an s at the end. Be sure not to type getElementByTagName(), which is not a valid method name.
Many programmers often name counter variables count, counter, or something similar. The letters i, j, k, l, x, y, and z are also commonly used as counter names. Using a name such as count, the letter i (for increment), or a higher letter helps you remember (and lets other programmers know) that the variable is being used as a counter.
As you can see in the syntax description, the statements execute before the conditional expression is evaluated. Unlike the simpler while statement, the statements in a do/while statement always execute at least once, before the conditional expression is evaluated the first time.
You can omit any of the three parts of the for statement, but you must include the semicolons that separate the sections. If you omit a section, be sure that you include code within the command block that will end the for statement or your program may get caught in an infinite loop.
Skills at Work When designing a program that involves loops, especially a large and complex program, it can be challenging to explain the structure of the program and the relationships between its parts to other team members who might be working with you to create it. It’s common for programmers to create a visual representation to illustrate the parts of a program and how they fit together, both before and during development. For loops, such diagrams often take the form of a flow chart, which shows program components as boxes of different shapes, with lines connecting those ...more
Recall that a falsy value is one of six values that are treated in comparison operations as the Boolean value false, and that a truthy value is any value other than the six falsy values.
Some developers add comments to their closing braces to indicate what statement each brace ends. For instance, after the first closing brace in Step 2, you might add the comment // end if to indicate that the brace closes the preceding if statement. Especially when your code includes structures nested several levels deep, such comments can make it easier to add or remove levels of nesting.