preloader
軟體工程

How do I use tools to debug CoffeeScript/Javascript files

I use following codes and tools to debug files of CoffeeScript/JavaScript:

  • Safari browser’s developer tool
    • set breakpoints at debugger tab of javascript files
    • responsive design mode of developer tool can help us to see what a web page is rendered.
  • coffeescript code
if myVariable? # this statement can check whether this variable has its value(s), null or undefined. If it has value, this statement would return true, otherwise false.
  alert JSON.stringify(myVariable,null,4) # to show this object's attributes and values of its attributes
else
  alert "null or undefined."
  • Another coffeescript code
if myVariable_2?.length # this statement can check whether this variable has its value(s), empty string, null or undefined. If it has value(s) or is an empty string, this statement would return true, otherwise false.
  alert JSON.stringify(myVariable_2,null,4)
else
  alert "null or undefined'