JavaScript Hungarian Notation Variable Prefix Naming Convention

Hungarian Notation is a language agnostic naming convention that prefixes variables with the variable's type. This allows the reader to determine the type and use of a variable by such an identifier.

JavaScript Hungarian Prefixes:

var aData = [1, 2, 3];
var bFound = false;
var fGoldenRatio = 1.618;
var fnCallback = function() { };
var iCurrentPage = 1;
var nNewRow = document.createElement("tr");
var oSettings = {
    type: "GET",
    url: "test.json",
    dataType: "jsonp"
};
var sLabel = "First Name";

Prefixes may also be combined where appropriate.

var asData = "foo,bar,baz".split(","); // Array of type String.

Examples in other languages:

int iNumber = 2;
$sQuote = "Imagination is more important than knowledge.";
$sMsg = "Example message string."
View this page on GitHub.
Posted .

Comments

Leave a Reply