How can I debug a function in Foundry Slate?

1.2k Views Asked by At

I've got several functions that are fairly long and complicated, and I want to debug them. Is there any built in debugging functionality to help me debug my complicated functions?

1

There are 1 best solutions below

0
On

You can use a debugger statement. Just insert debugger; anywhere in the function code as a breakpoint, and open your browser console. Now when you run your function, you will be able to use the full tools of the console debugger to help debug your functions! In particular, you'll be able to see the current values of your variables at that point in the code. In addition to this, you can use console.log(anyValue) to log the value of anyValue to the javascript console -- the equivalent of adding print statements to your code, which will also work to allow you see the values of variables and various other things in your code.

Part 3 of the Slate Getting Started tutorial, which is included in the Slate documentation, covers the use of the debugger and console logging in more depth.