Debugging in Lens Studio

The print function is great for simple stuff, but if you need to see some properties within an object, sometimes it just shows something like Object object which is very unhelpful.

One thing that helps for simple objects is to stringify the object first, like this: print(JSON.stringify(theObject))

That will work in some cases, but not in others. Sometimes you just get {} which is also very unhelpful.

I found this set of functions for debugging on github. I tried a few and they work nicely.

I do wish they had a depth option so you could set the level of traversal, but overall this is incredibly useful for anyone scripting in LS

3 Likes