你肯定见到过这样的代码:a = a||"xxx". 它其实就等价于下面三种形式的代码: a = a || "xxx"; 与: if (!a) { a = "xxx"; } 和: if (a == null || a == "" || a == undefined) { a = "xxx"; } 如何理解三种代码.首先必须理解一个问题: javascript 中的数据类型在与bool类型转换时候发生了什么?…
本文是翻译Function.apply and Function.call in JavaScript,希望对大家有所帮助 转自“http://www.jb51.net/article/52416.htm” 第一次翻译技术文章,见笑了! 翻译原文: Function.apply and Function.call in JavaScript 第一段略. 每个JavaScript函数都会有很多附属的(attached)方法,包括toString().call()以及apply().听起来,你是否会…