you really should use the “vectorized” version of that python code (see the edit to the answer there), not write loops at all !
let src = cv.imread('canvasInput');
let lab = new cv.Mat();
cv.cvtColor(src, lab, cv.COLOR_RGB2Lab);
let chan = new cv.MatVector();
cv.split(lab, chan);
let L = chan.get(0);
let A = chan.get(1);
let B = chan.get(2);
let ma = cv.mean(A)[0];
let mb = cv.mean(B)[0];
A = A - ((ma - 128.0) * (L / 255.0) * 1.1);
B = B - ((mb - 128.0) * (L / 255.0) * 1.1);
cv.merge(chan, lab);
let dst = new cv.Mat();
cv.cvtColor(lab, dst, cv.COLOR_Lab2RGB);
cv.imshow('canvasOutput', dst);