- chrome: <1> $_ :Returns the value of the most recently evaluated expression. <2> $0-$4 : Dev Tools remembers the last five DOM elements (or JavaScript heap objects) that you've selected in the tab (or Profiles panel). It makes those objects available as
$0
,$1
,$2
,$3
, and$4
.$0
returns the most recently selected element or JavaScript object,$1
returns the second most recently selected one, and so on. <3> $(selector) : Returns reference to the first DOM element with the specified CSS selector. <4>$$(selector):Returns an array of elements that match the given CSS selector. <5>$x(path):Returns an array of DOM elements that match the given XPath expression. <6>clear() <7> copy(object): Copies a string representation of the specified object to the clipboard.<8> dir(object): Displays an object-style listing of all the properties of the specified object. This method is an alias for the Console API's console.dir() method. <9>dirxml(),inspect(),getEventListeners(object):Returns the event listeners registered on the specified object <10> keys(object),Returns an array containing the names of the properties belonging to the specified object. To get the associated values of the same properties, use values(). <11> monitorEvents(object[, events]):When one of the specified events occurs on the specified object, the Event object is logged to the console. You can specify a single event to monitor, an array of events, or one of the generic events "types" that are mapped to a predefined collection of events.<12> profile([name]):Starts a JavaScript CPU profiling session with an optional name.<13>profileEnd([name]): Stops the current profiling session started with the profile() method and displays the results in the Profiles panel.<14>unmonitorEvents(object[, events]): Stops monitoring events for the specified object and events. <15>values(object): Returns an array containing the values of all properties belonging to the specified object. - Key Ideas: Load and go delivery; Loose typing; Objects as general containers; Prototypal inheritance; Lambda; Linkage though global variables
- Values: Numbers(double,typeof NaN,0.1+0.2,Number(),+ prefix operator,Math,parseInt ), String(UCS-2 not quite UTF-16,immutable,character is a String,== means Similar,single or double quotes,String(),length), Booleans( truthy(all other),falsy(false,null,undefined,'',0,NaN)), null, undefined
- Dynamic Objects:Unification of Object and Hashtables,new Object(), a name can be any String and a value can be any value except undefined, members can be accessed with dot notation or subscript notation,no hash nature is visible
- Loosely Typed: js is not untyped but loosely typed
- C: syntactically C family language, but allows functions to be values
- Identifiers: _, $, a letter; all variables,parameters,members,and function names start with lower case; _ should be reserverd for implementations and $ should be reserved for machines
- Reserved words
- Comments: //,/**/
- Operators:+ add, concatenation, Unary( +"100"); ===; !! get a boolean type;
- Statements: throw new Error(reason); throw{name:exceptionName,message:reason};try{}catch{};with(){} ,不推荐;function(){};var
- Scope,{block} do not has a scope; only function scope in js; var only visible in function
- Return statement; return undefined if there is no value; constructor will return this if no value or an Object
- Collections: an Object is an unordered collection of name/value pairs, Names are strings, values are any type including other objects, good for representing records and trees, every Object is a little database;
- Object Literals: {name:value,name:value,...}
- Maker function, return new Object
- Object Augmentation: new members can be added to any object by simple assignment, there is no need to define a new class
- Linkage: Objects can be create with a secret link to another object, if an attempt to access a name fails the secret linked object will be used, the secret link is not used when storing, new members are only added to the primary object, the object(o) function makes a new empty object with a link to object o
- Prototype Inheritance
- Object Methods: all objects are linked directly or indirectly to Object.prototype, all objects inherit some basic methods,none of them are very useful,hasOwnProperty(name)
- new Object(); {}; Object(Object.prototype)
- Reference: Objects are passed by reference, not by value; === compares the reference not values
- Delete myObject[name]
- Array: length, Array Literals []
- Distinguishing Array: value.constructor===Array, value instanceof Array
- Arrays and Inheritance: don't use arrays as prototype, you can augment an Individual array (assign a method to it), you can augment all arrays(assign methods to Array.prototype)
- Functions: Functions are first-class objects; functions can be passed ,returned,and stored just like any other value;Functions inherit from Object and can store name/value pairs
- Function operator
- lambda
- function statement
- inner functions
- Scope
- Closure
- Function Objects: can contain name/value pairs
- Method: function in an Object
- Invocation: if a function is called with too many arguments , extra parameters will be ignored; if a function is called with too few arguments, the missing values will be undefied
- four ways to call a function: <1> Function form: functionObject(args) <2>Method form:thisObject.methodName(args),thisObject['memberName'](args) <3>Constructor form: new functionObject(args) <4>Apply form: functionObject.apply(thisObject,[arguments])
- this
- arguments
- diy: trim, supplant
- typeof
- eval(string), 不推荐
- new Function(parameters,body)
- 避免使用 wrapper: new Number(), new String() , ...
- Confession
- Augmentation
- global object: on browser, window is the global object, global variables are evil
- implied Global , JSLint检查不严谨的地方
- every object is a separate Namespace, used to organizing the variables
- thinking about type
- threads: the language definition is neutral on threads
- ActionScript
- E4X, by BEA
- ECMAScript 4
- Style and JavaScript
- Semicolon insertion
- Line Ending
- Comma
- Required Blocks
- Forbidden Blocks
- Variables
- Expression Statements
- https://www.youtube.com/user/yuilibrary?feature=watch
转载于:https://www.cnblogs.com/dmdj/p/3413318.html