摘要:
var func = function (callback, a, b, c) { return callback(a, b, c);}var funAdd = function (a, b, c) { function callback(a, b, c) { return a + b + c; } return func(callback, a, b, c);}var funMul = function (a, b, c) { function callback(a, b, c) { return a * b * c; } return func(callbac... 阅读全文
摘要:
num = 123;str = "123";alert(num == 123); //truealert(str == 123); //truealert(num === 123); //true; 值相同且类型相同alert(str === 123); //falsealert(typeof num === "number"); //truealert(typeof str === "string"); //true//数组的类型也是 objectalert(typeof []); //objectalert(typeof {}); 阅读全文
摘要:
/* 默认参数 */function func(a, b, c) { a = a === undefined ? 3 : a; //默认 3 b = b === undefined ? 3 : b; //默认 3 c = c === undefined ? 3 : c; //默认 3 return a + b + c;}alert(func(6, 6, 6)); //18alert(func()); //9alert(func(4)); //10alert(func(4, 0)); //7/* 通过闭包预置参数 */function fu... 阅读全文
摘要:
在看几个 js 源码; 感觉不如 Delphi 的代码清晰, js 太灵活性, 需慢慢适应./* 定义一组常量(变量) */var MX1 = function () { };MX1.Max = 100;MX1.Min = 0;MX1.Ave = 50;alert(MX1.Max + ", " + MX1.Min + ", " + MX1.Ave); //100, 0, 50alert(++MX1.Max); //101/* 定义一组函数 */var MX2 = function () { };MX2.Add = function (a, b) { re 阅读全文