<script> // var c=[2,4,3,5,2,2,2], // a = {}, // i = 0; // for(;i<c.length;i++){ // a[c[i]] = 1 // } // c=[]; // for(var g in a){ // c.push(g-0); // } // console.log(c); //删选数组中有无重复的数字 // var pattern1 = /s/; //空格 // console.log(pattern1.test("njkhjkjk ")); //检查英文字是否有空格 // var nums = "132153132135", // ary = []; // nums.replace(/d{1,3}/g,function(num){ //d为正则,每三个分一组推入数组 // ary.push(num); // }); console.log(ary); // console.log(Math.max.apply(null,ary));把数组中最大的那个打印出来 // var o = new Object(); // o.s=1; // // console.log(o.constructor); // if("toString" in o){ // console.log("youshuxing"); // } // var ele = document.getElementById("test"); // if("placeholder" in ele){ // alert("支持"); // }else{ // alert("bu支持"); // } // var name = "xu", // preson ={ // name:"ren", // say:function(){ // // var that = this; // // console.log(this.name); // var a =function(){ // console.log(this.name); // }; // a.call(preson); // } // }; // preson.say(); // function person(name,age,job){ // this.name = name; // this.age = age; // this.job = job; // } // person.prototype.sayname=function(){ // return this.name; // } // console.log(person.prototype.constructor); // var ren = new person("ren",22,"teacher"); // var xu = new person("xu",18,"doctor"); // console.log(ren.sayname()); // console.log(xu.sayname()); // ren.name = "lin"; // console.log(ren.sayname()); // console.log(ren.__proto__); // console.log(person.prototype.constructor); // console.log(person.prototype.isPrototypeOf(ren)); // console.log(Object.getPrototypeOf(ren) == person.prototype); // console.log(Object.getPrototypeOf(ren).sayname); // console.log(Object.keys(person.prototype)); // console.log(Object.getOwnPropertyNames({})); // function Person(){ // } // Person.prototype = { // constructor:Person, // name : "xu" // } // var friend = new Person(); // console.log(friend.name); Number.prototype.add=function(num){ return this + num; } console.log((2).add(3)); String.prototype.Ltrim=function(){ return this.replace(/s/g,""); } console.log("1 2 3".Ltrim());