I came across this code snippet in our code base:
function initDoughnutChart(target) {
var labels = $(target).data("labels").toString().split(",");
var dataString = $(target).data("chart-data").toString();
// single-entry values
if (typeof dataString === 'number') {
dataString = dataString.toString();
}
var data = dataString.split(",");
...
Am I right to think the if statement is redundant as dataString is initialised to the value <something>.<something>.toString() thus it will (always?) have a type of 'string' (unless its initialisation throws but then the if won't be reached at all).