This is my study book of JavaScript Definitive Guide 6th Edition.
An Object is an unordered collection of properties, each of which has a name and a value. Property names are strings, so we can say that object map strings to values. This string-to-value mapping goes by various names: “hash”, “hashtable”, “dictionary” or “associative array”. An Object is more than a simple string-to-value map, however. A JS Object also inherits the properties of another object, know as its “prototype”. Any value in JS that is not a string, a number, true, false, null or undefined is an object. And even though strings, numbers, and booleans are not objects, they behave like immutable objets. If the variable x refers to an object, and the code var y = x; is executed, the variable y holds a referece to the same object, not a copy of that object.
A property has a name and a value. A property name may be any string, including the empty string, but no object may have two properties with the same name. The value may be any JS value, or (in ECMAScript 5) it may be a getter or a setter function (or both). In addition to its name and value, each property has associated values that we’ll call property attributes: - The writable attribute specifies whether the value of the property can be set. - The enumerable attribute specifies whether the property name is returned by for/in loop. - The configurable attribute specifies whether the property can be deleted and wheter its attributes can be altered.
Prior to ECMAScript 5 (BTW, node uses ECMAScript 5 :)), all properties in objects created by your code are writable, enumerable, and configurable. In ECMAScript 5, you can configure the attributes of your properties.
In addition to its properties, every object has three associated object attributes: - An object’s prototype is a reference to anther object from which properties are inherited. - An object’s class is a string that categorizes the type of an object. - An object’s extensible flag specifies (in ECMAScript 5) wheter new properties may be added to the object.
read moreThis is my study book of JavaScript Definitive Guide 6th Edition.
A JS program is simply a sequence of statements, separated from one another with semicolons.
{
var x = 10, y = 12;
function fn (v) {
--y;
return ++v;
}
fn(x);
console.log(x, y);
fn(y);
console.log(x, y);
console.log(fn(x), fn(y));
console.log(x, y);
}
console.log(x, y);
The curly braces are optional and does only one thing, let your code more readable.
JavaScript does not have block scope and variables declared within a statement block are not private to the block
A compound statement allows you to use multiple statements where JavaScript syntax expects a single statement. The empty statement is the opposite: it allows you to include no statements where one is expected. like:
read moreThis is my study book of JavaScript Definitive Guide 6th Edition.
An expression is a phrase of JS that a JS interpreter can evaluate to produce a value
Simplest expressions are known as primary expressions, are those that stand alone
When an object creation expression is evaluted, JS first creates a new emmpty object, next, it invokes the specified function with the specified arguments, passing the new object as the value of the this keywords.
Functions written for use as constructors do not return a value, and the value of object creation expressions is the newly created and initialized object. If a constructor does return an object value, that value becomes the value of the object creation expression and the newly object is discarded.
Nice table of operators is in Pag. 80
Unary + and - tries to convert his value into Number and positive or negative
read moreUnicode character set, case-sensitive, whitespace and line breaks are ignored. The JS Interpreter assumes that the source code it is interpreting has already been normalized and makes no attempt to normalize identifiers, strings or regular expressions itself.
undefined is not a reserved word, is a special type of var.
Semicolons (;) are optionals in some cases, JS treats a line break as semicoln if the next nonspace character cannot be interpreted as a continuation of the current statement.
In JS strings are compost by 16bits each letter.
Words from: JS Definitive Guide 6th Edition
Roughly, an expression is something that computes a value but doesn’t do anything: it doesn’t alter the program state in any way. Statements, on the other hand, don’t have a value (or don’t have a value that we care about), but they do alter the state.
commentThe other broad category of statement is control structures, such as conditionals and loops.
GRASP = General Responsibility Assignment Software Patterns
The critical design tool for software development is a mind well educated in design principles. It is not the UML or any other technology.
RDD - Responsibilities and Responsiblity-Driven Design
RDD is a general metaphor for thinking about OO software design. Think of software objects as similar to people with responsibilities who collaborate with other people to get work done. RDD leads to viewing an OO design as a community of collaborating responsible objects.
In OO design, a pattern is a named description of a problem and solution that can be applied to new contexts; ideally, a pattern advises us on how to apply its solution in varying circumstances and considers the forces and trade-offs.
Most simply, a good pattern is a named and well-known problem/solution pair that can be applied in new contexts, with advice on how to apply it in novel situations and discussion of its trade-offs, implementations, variations, and so forth.