11 2010 档案
摘要:最近在研究js,疑惑也比较多。主要是被原型这个东西给弄迷糊了。疑惑出自于:function foo { this.name = 'foo';}alert(foo.prototype === Function.prototype ); //false。 当时一直没想明白为啥foo的原型不是Function.prototype。下面例子让我想当然的认为o.prototype === Function...
阅读全文
摘要:块级作用域:大多数使用c语言语法的语言都有块级作用域,而JavaScript没有块级作用域。如代码块if (true) { inti = 100;}print(i); //错误,变量i没有声明如上面例子所示,代码块外的函数是无法访问i变量的。但在javaScript里,情况则完全不同。if (true) { var i = 100;}alert(i); //弹出框并显示100很多现代语言都推荐尽可...
阅读全文
摘要:JavaScript的假值列表如下, 值 类型 0 Number NaN (非数字) Number '' (空字符串) String false Boolean null Object undefined Undefined 以上的值作为判断条件,都将为假值,如:if(undefined){ alert('undefined');//这行代码不会执行}while(null){ alert('n...
阅读全文
摘要:1.html文件第一行要放Document Type, 以防浏览器使用Quirks模式来解析页面[代码]2. html一定要有head和body。head里面一定要有meta(指的是指定此html编码的meta,如meta http-equiv=”Content-Type” content=”text/html; charset=utf”,且一定要作为head的第一个子元素,保证浏览器成功解析title的内容)和title。3.p里不能放block element,blockquote里一定要放block element。4.body里只能放bloc
阅读全文