I came accross a code block in javascript. Can you please tell me its meaning?
var result = {
diagmetric : diag * 2.54,
sizex : xd,
sizey : yd,
metricsizex : 2.54*xd,
metricsizey : 2.54*yd,
xppi : x/xd,
yppi : y/yd,
dotpitch : pitch,
sqppi : x/xd*y/yd
};
Full function :
function calc_dpi (x,y,diag) {
if (y == 0 || x == 0) return;
var ratio = y/x;
var xd = Math.sqrt( Math.pow(diag,2) / ( 1 + Math.pow(ratio, 2) ));
var yd = xd * ratio;
var pitch = 25.4/(x/xd); // metric
var result = {
diagmetric : diag * 2.54,
sizex : xd,
sizey : yd,
metricsizex : 2.54*xd,
metricsizey : 2.54*yd,
xppi : x/xd,
yppi : y/yd,
dotpitch : pitch,
sqppi : x/xd*y/yd
};
return result;
}
Here you asign the Object to the
resultvar. In JS you can define the fields in the object this way: