<script> <!--第一种写法,我更喜欢第一种写法直观一些--> function Person(name){ this.name = name || '默认名字乔丹'; } var person = new Person('詹姆斯01');//this-->person console.log(person.name,'看啥名字')//詹姆斯01,如果不传递参数或者传递的参数为假(比如'',null)---就是默认的乔丹 <!--第2种写法--> func…
函数在执行时,会在函数体内部自动生成一个this指针.谁直接调用产生这个this指针的函数,this就指向谁. 怎么理解指向呢,我认为指向就是等于.例如直接在js中输入下面的等式: console.log(this===window);//true 情况不同,this指向的对象也不同.例如: 1. 函数声明的情况 var bj=10; function add(){ var bj=20; console.log(this);//window console.log( console.log(b…
我的移动端media html{font-size:10px} @media screen and (min-width:321px) and (max-width:375px){html{font-size:11px}} @media screen and (min-width:376px) and (max-width:414px){html{font-size:12px}} @media screen and (min-width:415px) and (max-width:639px){…