How to Log and Debug in JXA?

####What is the JXA equivalent of the AppleScript “log” command?
I’m running Yosemite 10.10.5

OK, I feel really dumb for having to ask this question, but I’ve been searching everywhere for over an hour, and can’t find the answer.
I’ve read and reread the Apple JXA documents, and JXA Cookbook, and every other article/blog I can find.

I need to output variables to the Script Editor Results pane.

I’ve tried the following without success.
I must be missing something very simple. :weary:

log('hello world');
console.log('hello world');

var app = Application.currentApplication()
app.includeStandardAdditions = true

app.log('hello world')

The answer:
console.log("hello world")

What can I say? I must be an idiot, and blind.

Here's what I was seeing at first:

Thinking that it mean an error.

I don't know how I forgot to click on the other Results tabs.
Then you see this:

I hope this will help any other blind people out there.

In my defense, I do have to say this: I find it amazing that nowhere in the documents and blogs I read did it explicity state to use "console.log( )".
But, then I am blind, so who knows. :sunglasses:

I hope you guys enjoyed the KM laugh-for-the-day! :laughing:

1 Like

Re debugging, if you are running OS X 10.11, you can step through lines of JXA code and watch all the variables changing their value in the Safari Webkit debugger;

1 Like

Thanks for the tip Rob.
Unfortunately, I’m still on Yosemite, and probably won’t upgrade to El Capitan for 6-12 months. I need to wait until most of the El Capitan bugs are fixed, and the apps I rely on work smoothly on it.