码迷,mamicode.com
首页 > Web开发 > 详细

js高级程序设计

时间:2017-07-08 16:59:14      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:程序设计   ons   高级   全局变量   事件   返回   erro   浏览器   console   

defer 异步脚本,脚本延迟到文档完全被解析和显示之后再执行。只对外部脚本文件有效。按顺序执行脚本。但在实际情况下,并不一定会按照顺序执行
最好只有一个延迟脚本。
支持H5的浏览器会忽略给脚本设置 defer 属性
async 异步脚本,不保证按脚本的先后顺序执行。
异步脚本一定会在页面的Load事件前执行。

IE10+支持严格模式

function test (){
     a = 12;    //没有var, a 是全局变量, 不推荐  严格模式下会报错 ”use strict" 
}
test();
console.log(a);  // 12

var num = 12;  // 推荐加; 
if(a){
   return true;   //  推荐加{}
}

5种基本数据类型 undefined null boolean number string
1种复杂数据类型 object          array function这两个呢?

typeof   undefined  null 

技术分享
console.log(typeof null);  // object
console.log(typeof 333);   // number
function abc () {
  return 5;
}
console.log(typeof abc);  // function

// undefined
var a;   // 默认会有一个 undefined值 
console.log(typeof a);  // undefined
console.log(typeof name);  // undefiend    不定义也是 Undefiend
var b = undefined
console.log(b === undefined);  // true
console.log(typeof undefined); // undefined

// null
var a = null;  // 空对象指针
console.log(typeof a); // object

// 如果定义的变量b 准备用于保存对象,那么var b = null  感觉没啥用
var b = null
b = {"name": ‘kang123‘}
if (b) {  // if(b!= null)
  console.log(b.name);
}
console.log(null === undefined);  // false  类型不一致
console.log(null == undefined);   //  true   undefined 值是派生null值的 ,ECMA-262 规定两者相等
View Code

  返回false 

var a = NaN
if(a){
  console.log(‘ok‘);
}else{
  console.log(‘error‘);  // undefined null 0 false ‘‘ NaN 
}

 

js高级程序设计

标签:程序设计   ons   高级   全局变量   事件   返回   erro   浏览器   console   

原文地址:http://www.cnblogs.com/gyz418/p/7137112.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!