function Worker(name, job){ Person.apply(this,arguments) this.job = job; } for(var i in Person.prototype){ Worker.prototype = Person.prototype; } new Worker(‘sl‘, ‘coders‘).showName();*/
//7,FF下面实现outerHTML /*var oDiv = document.createElement(‘div‘); var oDiv1 = document.getElementById(‘div1‘); var oWarp = document.getElementById(‘warp‘);
function getStrlen(str){ var json = {len:0}; var re = /[\u4e00-\u9fa5]/; for (var i = 0; i < str.length; i++) { if(re.test(str.charAt(i))){ json[‘len‘]++; } }; return json[‘len‘]+str.length; }*/
//9,编写一个方法 去掉一个数组的重复元素 /*var arr = [1,2,3,1,43,12,12,1]; var json = {}; var arr2 = []; for (var i = 0; i < arr.length; i++) { if(!json[arr[i]]){ json[arr[i]] = true; }else{ json[arr[i]] = false; }
if(json[arr[i]]){ arr2.push(arr[i]); } };
for (var i = 0; i < arr.length; i++) { if(!aa(arr[i], arr2)){ arr2.push(arr[i]) } }; function aa(obj, arr){ for (var i = 0; i < arr.length; i++) { if(arr[i] == obj) return true; else return false; }; } alert(arr2)*/