Common Javascript alerts methods

So here are some common javascript message alerts methods (common texts, variable values and lengths) widely used for testing and debugging.

There are also some useful methods with displaying alerts on condition and with returning values.

// Common javascript alert methods
var C = {
    A: function (AlertMessage) {
    alert(AlertMessage);
},
Av: function (AlertMessage, AlertValue) {
    alert(AlertMessage + " = " + AlertValue);
},
Ar: function (ReturnValue, AlertMessage) {
    alert(AlertMessage);
    return ReturnValue;
},
Al: function (AlertMessage, AlertValueLength) {
    alert(AlertMessage + " = " + AlertValueLength.length);
},
Ai: function (AlertOnTrueCondition, AlertMessage, AlertValue) {
    if (!AlertOnTrueCondition)
        return;

    if (AlertValue !== undefined)
        alert(AlertMessage + " = " + AlertValue);
    else
        alert(AlertMessage);
}
};

Usage is very simple :

C.A("My test message");  // alert message
C.Al("My val length", MyVal);  // display MyVal length
C.Av("My val value", MyVal);  // display MyVal value
return C.Ar(MyVal, "My Test message");  //  display message and return MyVal

Leave a Reply