<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <script type="text/javascript"> var arr = [1, 23, 1, 1, 1, 3, 23, 5, 6, 7, 9, 9, 8, 5]; var o = {}; // var new_arr = [];//新数组 for(var i = 0; i < arr.length; i++) { var k = arr[i]; if(!o[k]) { o[k] = true; new_arr.push(k); } } console.log(new_arr); </script> </body> </html> <!-- 利用空对象来记录新数组中已经存储过的元素 -->