Guest User

Untitled

a guest
Feb 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. ## 1. Select DOM Elements
  2.  
  3. Find one element
  4.  
  5. ```JavaScript
  6. $('<CSS_SELECTOR>');
  7. ```
  8.  
  9. Find all elements
  10.  
  11. ```JavaScript
  12. $$('<CSS_SELECTOR>');
  13. ```
  14.  
  15. ## 2. Convert Your Browser Into An Editor
  16.  
  17. ```JavaScript
  18. document.body.contentEditable = true;
  19.  
  20. // or
  21.  
  22. document.designMode = 'on';
  23. ```
  24.  
  25. ## 3. Find Events Associated with an Element in the DOM
  26.  
  27. ```JavaScript
  28. getEventListeners($('<CSS_SELECTOR>'));
  29. ```
  30.  
  31. Find a particular event
  32.  
  33. ```JavaScript
  34. getEventListeners($('<CSS_SELECTOR>')).eventName[0].listener;
  35. ```
  36.  
  37. ## 4. Monitor Events
  38.  
  39. ```JavaScript
  40. monitorEvents($('<CSS_SELECTOR>'));
  41. monitorEvents($('<CSS_SELECTOR>'), 'eventName');
  42. monitorEvents($('<CSS_SELECTOR>'), ['eventName1', 'eventName3', ...]);
  43. unmonitorEvents($('<CSS_SELECTOR>'));
  44. ```
  45.  
  46. ## 5. Find the Time Of Execution of a Code Block
  47.  
  48. ```JavaScript
  49. // Starts the timer with label - myTime
  50. console.time('myTime');
  51. // Ends the timer with Label - myTime
  52. console.timeEnd('myTime');
  53.  
  54. // Output: myTime:123.00 ms
  55. ```
  56.  
  57. ## 6. Arrange the Values of a Variable into a Table
  58.  
  59. ```JavaScript
  60. console.table(variableName);
  61.  
  62. // Example
  63. var myArray = [{a:1, b:2, c:3}, {a:1, b:2, c:3, d:4}, {k:11, f:22}, {a:1, b:2, c:3}];
  64. console.table(myArray);
  65. ```
  66.  
  67. ## 7. Inspect an Element in the DOM
  68.  
  69. ```JavaScript
  70. inspect($('<CSS_SELECTOR>'));
  71.  
  72. $0, $1, $2, etc
  73. ```
  74.  
  75. ## 8. List the Properties of an Element
  76.  
  77. ```JavaScript
  78. dir($('<CSS_SELECTOR>'));
  79. ```
  80.  
  81. ## 9. Retrieve the Value of your Last Result
  82.  
  83. ```JavaScript
  84. $_
  85.  
  86. // Example
  87. 2+3+4
  88. 9 //- The Answer of the SUM is 9
  89.  
  90. $_
  91. 9 // Gives the last Result
  92.  
  93. $_ * $_
  94. 81 // As the last Result was 9
  95.  
  96. Math.sqrt($_)
  97. 9 // As the last Result was 81
  98.  
  99. $_
  100. 9 // As the Last Result is 9
  101. ```
  102.  
  103. ## 10. Clear the Console and the Memory
  104.  
  105. ```JavaScript
  106. clear();
  107.  
  108. // Shortcut
  109. CTRL + L
  110. ```
  111.  
  112. ## 11. Copy something
  113.  
  114. ```JavaScript
  115. copy(<SOMETHING>);
  116. ```
Add Comment
Please, Sign In to add comment