js算法

//得到没有重复元素的数组

1 function getUniqueNodes(arr){
2   var result = [];
3   for(var i=0;i<arr.length;i++){
4     if(arr.indexOf(arr[i])==i){
5       result.push(arr[i]);
6     }
7   }   
8   return result;
9 }

//判断android还是iOS设备进行页面跳转

<script type="text/javascript">
  if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) { // alert(navigator.userAgent); window.location.href ="https://itunes.apple.com/cn/app/%E9%87%91%E6%89%8D%E5%AD%A6%E9%99%A2/id1332899101?mt=8" } else if (/(Android)/i.test(navigator.userAgent)) { window.location.href ="http://www.runoob.com/java/java-tutorial.html" }
</script>
//

posted @ 2018-02-11 10:43  音为  阅读(82)  评论(0编辑  收藏  举报