Skip to content

ETLaurent/bootcamp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Debug tips

Console

console.trace

function foo() {
  function bar() {
    console.trace();
  }
  bar();
}

foo();

console.time and console.timeEnd

(async () => {
  const startServer = () => new Promise(resolve => setTimeout(resolve, 1000))

  console.time('starting server')
  await startServer()
  console.timeEnd('starting server')
})()

console.table

console.table([
  { a: 1, b: 2 },
  { a: 3, d: 4 }
])

console.memory

// browser
console.memory

// node
console.log(process.memoryUsage())

console.count

['apple', 'banana', 'orange', 'banana'].forEach(console.count)

console.assert

console.assert(1 + 1 === 3, 'false!')

console.group (browser)

console.log('root')
console.group('level 1')
console.log('hey')
console.group('level 2')
console.log('ho')
console.groupEnd('level 2')
console.groupEnd('level 1'

Performance

performance.now()

const startServer = () => new Promise(resolve => setTimeout(resolve, 1000))

const t0 = performance.now()
startServer()
const t1 = performance.now()

console.log(`server took ${t1 - t0}ms to start`);
console.log(performance.timeOrigin)

Breakpoints

Browser

  • demo

Node

  • node --inspect
  • node --inspect-brk

Debug with Chrome

  • NiM extention

Debug with VSCode

{
  "type": "node",
  "request": "attach",
  "name": "Debug",
  "protocol": "inspector",
  "port": 9229,
  "restart": true
}

or pick which process to listen to:

{
  // ...
  "processId": "${command:PickProcess}"
}

Resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published