SOURCE

function isPrime(element, index, array) {
  var start = 2;
  while (start <= Math.sqrt(element)) {
    if (element % start++ < 1) {
      return false;
    }
  }
  return element > 1;
}
var arr = []
for (let i = 1; i< 101; i++) {
    arr.push(i)
}
console.log(arr.filter(isPrime))
console 命令行工具 X clear

                    
>
console