When debugging javascript, sometimes it's quite helpful to put alerts. Here's a function for Emacs to insert an alert that shows current file name and line number:

(defun js-insert-alert-at-here () (interactive) (insert (concat "alert(\"" (buffer-name) ": " (number-to-string (line-number-at-pos)) "\");")))

Labels: debug, emacs, javascript