Tern Demo

1
// Use ctrl-space to complete something
2
// Put the cursor in or after an expression, press ctrl-i to
3
// find its type
4
 
5
var foo = ["array", "of", "strings"];
6
var bar = foo.slice(0, 2).join("").split("a")[0];
7
 
8
// Works for locally defined types too.
9
 
10
function CTor() { this.size = 10; }
11
CTor.prototype.hallo = "hallo";
12
 
13
var baz = new CTor;
14
baz.
15
 
16
// You can press ctrl-q when the cursor is on a variable name to
17
// rename it. Try it with CTor...
18
 
19
// When the cursor is in an argument list, the arguments are
20
// shown below the editor.
21
 
22
[1].reduce(  );
23
 
24
// And a little more advanced code...
25
 
26
(function(exports) {
27
  exports.randomElt = function(arr) {
28
    return arr[Math.floor(arr.length * Math.random())];
29
  };
30
  exports.strList = "foo".split("");
31
  exports.intList = exports.strList.map(function(s) { return s.charCodeAt(0); });
32
})(window.myMod = {});
33
 
34
var randomStr = myMod.randomElt(myMod.strList);
35
var randomInt = myMod.randomElt(myMod.intList);
36
 
 

Demonstrates integration of Tern and CodeMirror. The following keys are bound:

Ctrl-Space
Autocomplete
Ctrl-I
Find type at cursor
Alt-.
Jump to definition (Alt-, to jump back)
Ctrl-Q
Rename variable

Documentation is sparse for now. See the top of the script for a rough API overview.