Professional Javascript 学习笔记 第一章

  • 通过"use strict”;声明js文件或方法使用strict模式。
  • javascript 6种数据类型:String,Number,Boolean,Object,undifined,function。可以通过typeof判断,typeof括号可选,因为typeof是一个operator,不是function。

var message; //this variable is declared but has a value of undefined
//var age
alert(typeof message); //”undefi ned”
alert(typeof age); //”undefi ned”

  • undefined is a derivative of null,so   alert(null == undefined); //true
  • alert(0 == false);alert(1 == true);//true     alert(undefined == false);alert(null == false);//false
  • 因为进制原因,要避免小数加减结果判断。alert(0.1+0.2 == 0.3);//false   alert(0.1+0.2 == 0.30000000000000004);//true
  • 一般浏览器的数字极值是Number.MIN_VALUE和Number.MAX_VALUE。Infinity和-Infinity代表正负无穷大。isFinite()方法可以判断数字是否有限。
  • NaN代表not a number。isNaN()方法可判断数字。isNaN(true);//true,因为true可以convert to 1.isNaN判断object对象时先调用valueof(),没有调用toString();
  • 有三个方法转换数字,Number(),parseInt(),parseFloat()。Number(true)是1,Number(false)是0。parseInt(true)是NaN。
  • parseInt(“10”, 2);可以传进制给parseInt,防止不同版本js解析不同。
  • 大多数类型数据都有toString()方法,其中number的toString()方法可以传进制进去,显示不同进制的数字。null和undefined没有toString()。String()方法可以兼容null和undefined。
  • 每个Object对象都有如下方法。

构造方法

hasOwnProperty(propertyName) //是否包含某属性

isPrototypeOf(object)//是否为某对象prototype

propertyIsEnumerable(propertyName)//属性是否能用for in 枚举

toLocaleString()//返回平台相关属性

toString和valueOf通常一样,都是toString()。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
This book provides a developer-level introduction along with more advanced and useful features of JavaScript. Coverage includes: JavaScript use with HTML to create dynamic webpages, language concepts including syntax and flow control statementsvariable handling given their loosely typed naturebuilt-in reference types such as object and arrayobject-oriented programingpowerful aspects of function expressionsBrowser Object Model allowing interaction with the browser itselfdetecting the client and its capabilitiesDocument Object Model (DOM) objects available in DOM Level 1how DOM Levels 2 and 3 augmented the DOMevents, legacy support, and how the DOM redefined how events should workenhancing form interactions and working around browser limitationsusing the tag to create on-the-fly graphicsJavaScript API changes in HTML5how browsers handle JavaScript errors and error handlingfeatures of JavaScript used to read and manipulate XML datathe JSON data format as an alternative to XMLAjax techniques including the use of XMLHttpRequest object and CORScomplex patterns including function currying, partial function application, and dynamic functionsoffline detection and storing data on the client machinetechniques for JavaScript in an enterprise environment for better maintainability This book is aimed at three groups of readers: Experienced object-oriented programming developers looking to learn JavaScript as it relates to traditional OO languages such as Java and C++; Web application developers attempting to enhance site usability; novice JavaScript developers. Nicholas C. Zakas worked with the Web for over a decade. He has worked on corporate intranet applications used by some of the largest companies in the world and large-scale consumer websites such as MyYahoo! and the Yahoo! homepage. He regularly gives talks at companies and conferences regarding front-end best practices and new technology.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值