看JavaScript 一书中记的一些关键点

  1. JS在执行时才确定值(变量在初始化)

  2. JS引擎在解析时会预编译对所有变量和函数预先处理,所以执行时变量与函数都可见

  3. 先声明,再引用,在JS最上面先声明好变量OR函数,下面再使用

  4. 所有的JS块都属于同一个全局作用域

  5. 开发工具:Aptana Firebug HttpWatch

  6. try....catch...finally

  7. thow new Error("error msg")

    function customError(message){
     this.name = 'CustomError';
     this.message = message
    }
    
    customError.prototype = new Error()
    throw new customError("xxxx")
    
  8. JS 严格区分大小写

  9. 骆驼命名法

  10. JS可以不申名变量值,直接给值,但是会当为全局变量(var name = '' / name = '')

  11. 全局整个页面可以访问,局部仅在声明的函数中使用

  12. 避免变量污染,减少全局变量的使用,可以申明一个容器如:

    var my = {}
    my.name={
    	"fisrtName" : "A"
    	"lastName" : "B"
    }
    my.work = {
    	"number" : 12,
    	"time" : "2015-9-14"
    }
    
  13. JS的基本数据类型

  1. type of 可以检测基本数据类型

  2. 0.1+0.2=0.300000004浮点问题 ===>(1+2)/10 = 0.3

  3. NaN 非数字 ISNaN()

  4. Infinity 无穷大

  5. null 与 undefind 区别一个是定义

  6. 基本类型检测 typeof 返回值是字符串 constructor 返回值是属性值 toString 返回值是字符串

  7. 转换小数 toFixed(2) 小数2位 4舍5入

  8. parseInt()/parseFloat()

  9. 包含检测 "in" 检测属性 "a" in Object

  10. Instanceof 对象类型检测

  11. new 实例化新对象

    var a = {
    	this.x = 1
    	this.y = 2
    }
    
    var b = new a;
    
  12. delete 删除属性,数组元素,变量

  13. for/in for(var b in a){}

转载于:https://my.oschina.net/SpringZhang/blog/1885455

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值