Douglas Crockford: The JavaScript Programming Language

本文详细介绍了Chrome开发者工具中控制台的各种实用命令,包括选择DOM元素、性能分析、对象属性查看等功能,并深入探讨了JavaScript的基本类型、动态对象特性、原型继承等核心概念。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. 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.
  2. Key Ideas: Load and go delivery; Loose typing; Objects as general containers; Prototypal inheritance; Lambda; Linkage though global variables
  3. 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
  4. 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
  5. Loosely Typed: js is not untyped but loosely typed
  6. C: syntactically C family language, but allows functions to be values
  7. 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
  8. Reserved words
  9. Comments: //,/**/
  10. Operators:+  add, concatenation, Unary( +"100"); ===; !! get a boolean type; 
  11. Statements: throw new Error(reason); throw{name:exceptionName,message:reason};try{}catch{};with(){} ,不推荐;function(){};var
  12. Scope,{block} do not has a scope; only function scope in js; var only visible in function
  13. Return statement; return undefined if there is no value; constructor will return this if no value or an Object
  14. 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;
  15. Object Literals: {name:value,name:value,...}
  16. Maker function, return new Object
  17. Object Augmentation: new members can be added to any object by simple assignment, there is no need to define a new class
  18. 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
  19. Prototype Inheritance
  20. 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)
  21. new Object(); {}; Object(Object.prototype)
  22. Reference: Objects are passed by reference, not by value; === compares the reference not values
  23. Delete myObject[name]
  24. Array: length, Array Literals []
  25. Distinguishing Array: value.constructor===Array, value instanceof Array
  26. 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)
  27. 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
  28. Function operator
  29. lambda
  30. function statement
  31. inner functions
  32. Scope
  33. Closure
  34. Function Objects: can contain name/value pairs
  35. Method: function in an Object
  36. 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
  37. 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])
  38. this
  39. arguments
  40. diy: trim, supplant
  41. typeof
  42. eval(string), 不推荐
  43. new Function(parameters,body)
  44. 避免使用 wrapper:  new Number(), new String() , ...
  45. Confession
  46. Augmentation
  47. global object: on browser, window is the global object, global variables are evil
  48. implied Global , JSLint检查不严谨的地方
  49. every object is a separate Namespace, used to organizing the variables
  50. thinking about type
  51. threads: the language definition is neutral on threads
  52. ActionScript
  53. E4X, by BEA
  54. ECMAScript 4
  55. Style and JavaScript
  56. Semicolon insertion
  57. Line Ending
  58. Comma
  59. Required Blocks
  60. Forbidden Blocks
  61. Variables
  62. Expression Statements
  63. https://www.youtube.com/user/yuilibrary?feature=watch

转载于:https://www.cnblogs.com/dmdj/p/3413318.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值