Type hinting in JavaScript variables

JavaScript is a loosely typed language and has no notion of type hinting. Anyway, we can mimic this behavior by prefixing our variables with some letters that serve as a reminder to developers. Here are some prefixes:

Type prefixes
Prefix Type
o Object
s String
a Array
n Number

Some examples:

var aTest = ['a', 'b', 'c'];
var sBar = 'Bar';
var oFoo = new Foo();

Leave a Reply

Note: Only a member of this blog may post a comment.