Hungarian Notation Definition | Hungarian Notation List

Hungarian notation is a method of naming elements of code. It was introduced by Charles Simonyi from Microsoft. As a programmer, learning a scripting language like JavaScript, you should write a code good readable code.  This method helps make it easier to spot potential bugs before they happen and make code more understandable. Here are some Hungarian notation examples to elaborate how Hungarian notation is used JavaScript or other programming languages.

Prefix Explanation Example
b Boolean value bUnsubscribed
c, n Count of some number of items cEmployees, nTags
a, arr Array of items aNames, asNames
s String sEmpName
i Index into an array aCandidates[iCandidate]
r, c Row or Column of a table or DB cField
g_, m_ Scope level: global, member var g_sUniversityName

In the above table you can see that every kind of variable is given a name with a small letter on the start. The first is a Boolean value so its name is mentioned as bUnsubscribed, the letter ‘b’ shows that it is a Boolean value. The other variable names are easy to identify as well like sEmpName indicates that it is a string variable because it starts with a lover level letters.

Related Posts