Not sure what you mean? In a zimlet JavaScript Handler Object class? Yes, the "alert("...");" method will work.
But if you want better debugging in your zimlet javascript, you might want to use Firefox and Firebug. And with that, you get a "debugger;" command and a debug console in Firebug. You also get "console.log("...");" to print to the Firebug console.
ZCS 6.0:Zimlet Developers Guide:Firefox and Firebug - Zimbra :: Wiki