@mattzeunert
Fix Bugs
Understand Code
Cmd + Opt + F
Ctrl + Shift + F
$(document).ready(function(){
[1, 2, 3, 4].filter(function(n){
return n > 2
})
})
$(document).ready(function initApp(){
[1, 2, 3, 4].filter(function numberIsLargeEnough(n){
return n > 2
})
})
function calculateHolidayCost(){var t=0;t+=getFlightCost(
);t+=getHotelCost();t+=getFoodCost();debugger;return t}fu
nction getHotelCost(){return parseFloat("GBP200")}functio
n getFlightCost(){return 300}function getFoodCost(){retur
n 200}function onButtonClick(){var t=document.getElementB
yId("value");t.innerHTML=calculateHolidayCost()}
uglifyjs all.js
-o all.min.js
--source-map all.min.map
--mangle --compress
{
"version": 3,
"sources": [
"calculate-holiday-cost.js",
"get-hotel-cost.js",
...
],
"names": [
"calculateHolidayCost",
"cost",
...
],
"mappings": "AAAA,QAASA,wBACL,GAAIC,GAAO,CAMX...",
"file": "all.min.js"
}
{
"version": 3,
"sources": [...],
"names": [...],
"mappings": [
[0, 0, 0, 0],
[8, 0, 9, 9, 0],
[24, 0, 1, -5],
...
],
"file": "all.min.js"
}
function calculateHolidayCost() {
var t = 0;
return t += getFlightCost(),
t += getHotelCost(),
t += getFoodCost()
}
import React from "react"
// ==> Compiled to:
var _react = require("react");
var _react2 = _interopRequireDefault(_react);
{
"version": 3,
"sources": [
"calculate-holiday-cost.js",
"get-hotel-cost.js",
...
],
"names": [
"calculateHolidayCost",
"cost",
...
],
"mappings": "AAAA,QAASA,wBACL,GAAIC,GAAO,CAMX...",
"file": "all.min.js"
}
DevTools can pause on
var originalSetItem = localStorage.setItem;
localStorage.setItem = function(key, value){
debugger;
return originalSetItem.call(this, key, value);
}
Pause on:
Pause On:
Object.defineProperty(document.body, "scrollTop", {
set: function(){
debugger;
}
})
breakpoints.debugPropertySet(document.body, "scrollTop")
// or
breakpoints.debugScroll()
console.log("Post:", post);
Immutable DevTools
console.time("Loop");
for (var i=0; i<1000000; i++) { }
console.timeEnd("Loop")
Chrome Debugging Protocol
Chrome Desktop
DevTools
Chrome on Android
Node
$ node-debug test.js
Chrome Debugging Protocol
Node
DevTools
Node Inspector
V8-Debug Protocol
Chrome Debugging Protocol
Node
DevTools
$ node --inspect test.js
Chrome Debugging Protocol
Chrome Desktop
DevTools
Sublime Text
IntelliJ IDEA
Visual Studio Code
Slides