function isBooleanArray(arr, len) {
  return (
    Array.isArray(arr) &&
    (len === null || arr.length === len) &&
    arr.every(x => typeof x === "boolean")
  );
}
Checks if something is an Array containing only boolean values,
and (optionally) checks its length.
@param {any} arr
@param {number | null} len
@returns {boolean}