β
The properties of an object are automatically exposed, whereas the variables in a closure are automatically hidden.
β
β
David Herman (Effective JavaScript: 68 Specific Ways to Harness the Power of JavaScript)
β
Generative testing is an approach to testing software that was made popular by the QuickCheck library. Originally written in Haskell and since ported to several other programming languages (Ruby, Python, C, C++, Objective-C, Smalltalk, Java, JavaScript, Erlang, Scala, Clojure...), the QuickCheck library allows the developer to separate test logic from the generation of test cases. This means that, as developers, we can spend less time instructing the compiler how to test our code, and focus instead on what properties we expect our code to have.
β
β
Anonymous
β
When you declare any kind of global variable or define a global function, it is stored as a property in the window object. So
β
β
Eric Freeman (Head First JavaScript Programming: A Brain-Friendly Guide)
β
Math is not a constructor, or even a function. Itβs an object. As you know, Math is a built-in object that you can use to do things like get the value of pi (with Math.PI) or generate a random number (with Math.random). Think of Math as just like an object literal that has a bunch of useful properties and methods in it, built-in for you to use whenever you write JavaScript code. It just happens to have a capital first letter to let you know that itβs built-in to JavaScript.
β
β
Eric Freeman (Head First JavaScript Programming: A Brain-Friendly Guide)
β
If you change any property in the prototype, it affects all the objects that inherit from that prototype, unless that object has overridden that property.
β
β
Eric Freeman (Head First JavaScript Programming: A Brain-Friendly Guide)
β
methods in objects are properties too. They just happen to have a function assigned to them.
β
β
Eric Freeman (Head First JavaScript Programming: A Brain-Friendly Guide)
β
You can extend your object at any time with new properties. To do this you just specify the new property and give it a value. For
β
β
Eric Freeman (Head First JavaScript Programming: A Brain-Friendly Guide)
β
Window is the global object. It may seem a little weird, but the window object acts as your global environment, so the names of any properties or methods from window are resolved even if you donβt prepend them with window. In addition, any global variables you define are also put into the window namespace, so you can reference them as window.myvariable.
β
β
Eric Freeman (Head First HTML5 Programming: Building Web Apps with JavaScript)
β
Using a method to change a property is another example of encapsulation whereby we can often improve the maintainability and extensibility of code by letting an object worry about how it gets things done. Itβs
β
β
Eric Freeman (Head First JavaScript Programming: A Brain-Friendly Guide)
β
The hasOwnProperty method returns true if a property is defined in an object instance. If itβs not, but you can access that property, then you can assume the property must be defined in the objectβs prototype.
β
β
Eric Freeman (Head First JavaScript Programming: A Brain-Friendly Guide)
β
The try statement executes a block and catches any exceptions that were thrown by the block. The catch clause defines a new variable that will receive the exception object. The throw statement raises an exception. If the throw statement is in a try block, then control goes to the catch clause. Otherwise, the function invocation is abandoned, and control goes to the catch clause of the try in the calling function. The expression is usually an object literal containing a name property and a message property. The catcher of the exception can use that information to determine what to do.
β
β
Douglas Crockford (JavaScript: The Good Parts: The Good Parts)
β
Names A name is a letter optionally followed by one or more letters, digits, or underbars. A name cannot be one of these reserved words: abstract boolean break byte case catch char class const continue debugger default delete do double else enum export extends false final finally float for function goto if implements import in instanceof int interface long native new null package private protected public return short static super switch synchronized this throw throws transient true try typeof var volatile void while with Most of the reserved words in this list are not used in the language. The list does not include some words that should have been reserved but were not, such as undefined, NaN, and Infinity. It is not permitted to name a variable or parameter with a reserved word. Worse, it is not permitted to use a reserved word as the name of an object property in an object literal or following a dot in a refinement. Names are used for statements, variables, parameters, property names, operators, and labels.
β
β
Douglas Crockford (JavaScript: The Good Parts: The Good Parts)
β
The other form (called for in) enumerates the property names (or keys) of an object. On each iteration, another property name string from the object is assigned to the variable.
β
β
Douglas Crockford (JavaScript: The Good Parts: The Good Parts)
β
Values of type string, number, and Boolean are not objects, and though the language doesnβt complain if you try to set new properties on them, it doesnβt actually store those properties. As mentioned earlier, such values are immutable and cannot be changed. But these types do have built-in properties. Every string value has a number of methods.
β
β
Marijn Haverbeke (Eloquent JavaScript: A Modern Introduction to Programming)
β
A prototype is another object that is used as a fallback source of properties. When an object gets a request for a property that it does not have, its prototype will be searched for the property, then the prototypeβs prototype, and so on. So who is the prototype of that empty object? It is the great ancestral prototype, the entity behind almost all objects, Object.prototype.
β
β
Marijn Haverbeke (Eloquent JavaScript: A Modern Introduction to Programming)