Javascript has undoubtedly its great time nowadays. Not only it is used by web browsers but also became popular as an efficient server side solution (just to mention node.js) for many performance problems. Along with javascript growth we could observe raise and fall of dedicated IDEs. Years ago when I started my adventure with javascript I had to choose between Aptana and (paid) IntelliJ Idea. All other editors either supported javascript poorly or didn’t support it at all.

Today, looks like we have quite different situation. We have Sublime Text, Eclipse with tons of plugins, and (surprise) Emacs with js2-mode. If you are considering Emacs as your primary IDE for javascript - js2-mode is a must.

Recently, its co-author - Dmitry Gutov implemented one thing that convinced me to drop other editors (yes, including Sublime). Let’s start with a few words of explanation what the ‘imenu’ is.

Imenu mode is a list of functions and definitions gathered from current buffer. It allows you switching immediately between them just with few keys stokes. The list is presented either in system menu or as mini-buffer completion (which may be boosted by ido) or by awesome anything-imenu.

js2-mode supported imenu for a long time but it was not able to recognize few javascript constructions, thus the list of functions was horribly limited. I opened a ticket on github kindly trying to ask Dmitry for a few enhancements.

And voila! Since June we may admire js2-mode with imenu in action having code like this (backbone based):

App.Views.Shelf = Backbone.View.extend({
    template: JST['app/shelf'],
    el: '#container .shelf',
    events: {
    },
    initialize: function() {
    },
    render: function() {
    }
})

or ‘module’ patterns like this:

(function($) {
    return {
        bar: function() { }
    };
})(jQuery);

The pleasure of using Emacs with javascript has just raised by 100% :)

Thanks Dmitry!