摘要: // version 1.0.0 create 2017-05-22 /** * JavaScript 运算符 */ // instanceof var box = { color: "red" }; box instanceof Array; // false var box = [1, 2]; box instanceof Array; // true /** * Jav... 阅读全文
posted @ 2017-04-19 12:01 蒲木杉 阅读(181) 评论(0) 推荐(0) 编辑
摘要: // encodeURI() 把字符串编码为 URI。对中文编码。 encodeURI("//lee李"); // "//lee%E6%9D%8E" // encodeURIComponent() 把字符串编码为 URI 组件。对特殊字符(//)和中文编码。 encodeURIComponent("//lee李"); // "%2F%2Flee%E6%9D%8E" // decodeURI() ... 阅读全文
posted @ 2017-04-19 11:26 蒲木杉 阅读(150) 评论(0) 推荐(0) 编辑
摘要: /* * 基本类型 string 和包装类型 String * 都可以调用系统内置的方法 但是基本类型不能为自己添加属性和方法 包装类型可以为自己添加属性和方法 */ // 定义基本类型 string var box = "lee"; // 调用内置方法 substring() box.substring(); // "lee" // 添加属性和方法 box.name = 'zhang';... 阅读全文
posted @ 2017-04-19 11:09 蒲木杉 阅读(140) 评论(0) 推荐(0) 编辑
摘要: // 把数字转换为字符串,使用本地数字格式顺序。 var box = 1000; box.toLocaleString(); // "1,000" // toFixed(num) 把数字四舍五入为指定小数位数num的字符串。 var box = 1.2365; box.toFixed(2); // "1.24" // 以指数形式输出 var box = 1000; box.toExponen... 阅读全文
posted @ 2017-04-19 09:52 蒲木杉 阅读(176) 评论(0) 推荐(0) 编辑
摘要: // 返回算术常量 e,即自然对数的底数(约等于2.718)。 Math.E; // 2.718281828459045 // 返回圆周率(约等于3.14159)。 Math.PI; // 3.141592653589793 // 返回最低值。 Math.min(1, 2, 3, 4, 5, 6); // 1 // 返回最高值。 Math.max(1, 2, 3, 4, 5, 6); // 6 ... 阅读全文
posted @ 2017-04-19 09:46 蒲木杉 阅读(188) 评论(0) 推荐(0) 编辑