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();

Type hinting in PHP variables

PHP provides only a basic implementation of type hinting, namely for arrays and objects. Currently there's no way to determine if a given variable is a string, a boolean, an object or anything else. Thus, many PHP developers prepend a prefix to each variable name in order to determine if a given variable contains a certain type. The following table summarizes some possible prefixes:

Prefix Meaning
ar array
bl boolean
obj object
str string

Some examples:

$strUA = $_SERVER['HTTP_USER_AGENT'];
$arBrowserInfo = get_browser(null, true);

In my opinion, this is a useful way to improve the overall readability of our code. By doing so, we'll stop asking to ourselves whether a given variable contains a certain type or not.