impact of null object refs in jquery?
Hello - In jQuery is there any impact to calling methods on object references that don't exist? For example, consider the following:
var currencyFields = {'aMyCurrX','aMyCurrY','aMyCurrZ'};
$(
$.each(currencyFields, function(i){ FormatCurrency(currencyFields[i]); });
);
function FormatCurrency(fieldId)
{
//just a placeholder for now
alert($('#' + fieldId).value());
}
In the example above, the page is generated dynamically and not all curr fields will necessarily exist on the generated page. Defining these fields in a simple array will provide the best simplicity/maintainability.
But how does jQuery handle these errors? Is some error event triggered if jquery tries to exist a null object? If not then is there any practical downside to using this approach against a small array of values? Are there any scenarios that could potentially present gotchas with this approach?