//字面量的形式创建原型对象 /* function Box(){} Box.prototype={ 'name':'gao', age:23, fun:function(){ return this.name+'--'+this.age; } } var box1=new Box(); console.log(box1.age) console.log(box1.constructor) */ //1.使用字面量后constructor会指向Object,因为Box.prototype={}这种写法创建了一个新的对象导致. //解决方式如下: function Box(){} Box.prototype={ constructor:Box, 'name':'gao', age:23, fun:function(){ return this.name+'--'+this.age; } } var box1=new Box(); console.log(box1.age) console.log(box1.constructor) //2.原型对象不仅仅在自定义对象中可以使用,内置的引用类型都可以使用,并且本身页使用了原型 var box2=[1,15,9,8,6,12]; console.log(Array.prototype.sort()); //3.给原型增加方法 String.prototype.addstring=function(){ return this+'-Hello!'; } console.log('China'.addstring());
WebSql的原理是浏览器集成了sqllite数据库,Js操作,浏览器协助完成,没有多复杂。<!-- 三个核心方法  ...
离线缓存的开启实例使用apache设置 1.apache配置文件搜索Addtype,我的addtype已经存在项目,如下 AddType application/x-compress .Z AddType application/x-gz...
TmodJS是一套完整的前端模块框架。 虽然我们PHP框架自带各种模板引擎,但是始终是后端模板引擎。例如我们在使用ThinkPHP3.2.3中如果是Ajax异步加载页面,拼接HTML真的是很头疼的一件事情。...
<!doctype html> <html> <head> <meta charset="utf-8"> <title>无标题文档</title> <script type...
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>获取mac地址</title> </head&g...
查看文章前你需要了解以下2点://1.this指向的是windows对象,通过console.log(this)可以查看到对象包含所有的方法和属性//2.全局变量属于this对象的属性通过console.log(this)可以查看到对象包含我们设置的全局变量我们经常在创建相同结构的Js对象会重复的设...