So it's a stream, not a list, because those have a length.
Of course, as JS doesn't do (guaranteed) tail call optimisation, even finite lists will have "no length" ;)
(and first rewriting `length` to be tail recursive (or using a loop with mutation):
function length(l) {
function go(l, acc) {
if (l == null) {
return acc;
} else {
return go(l.rest, acc + 1);
}
}
return go(l, 0);
} (define l '(1 2 3))
(set-cdr! (cddr l) l)