晴明的博客园 GitHub      CodePen      CodeWars     

文章分类 -  JavaScript

上一页 1 ··· 8 9 10 11 12
摘要:let 可替代 var 声明变量,但 let 声明的变量只在它所在的代码块有效。 特别适用于 for()循环中。 这是分割线 const 声明常量,常量无法被改变。 这是分割线 箭头函数(=>) function friend = friends => friends.filter(friend = 阅读全文
posted @ 2016-02-04 11:40 晴明桑 阅读(87) 评论(0) 推荐(0)
摘要:#通用封装方法 #JS简易写法 console.log(object[, object, ...])使用频率最高的一条语句:向控制台输出一条消息。支持 C 语言 printf 式的格式化输出。当然,也可以不使用格式化输出来达到同样的目的:var animal='frog', count=10;con 阅读全文
posted @ 2016-02-02 18:08 晴明桑 阅读(143) 评论(0) 推荐(0)
摘要:#cookie必须经过URL编码 #getCookie #setCookie #unsetCookie # #SubCookie # function getCookie(name) { var result = null; var myCookie = document.cookie + ";"; 阅读全文
posted @ 2016-01-21 15:25 晴明桑 阅读(145) 评论(0) 推荐(0)
摘要:window.addEventListener("copy", function(event){ console.log("copy"); event.preventDefault(); }); 阅读全文
posted @ 2016-01-21 14:28 晴明桑 阅读(142) 评论(0) 推荐(0)
摘要:"西瓜".charCodeAt(0); //35199"西瓜".charCodeAt(1); //29916String.fromCharCode(35199,29916) //西瓜 阅读全文
posted @ 2016-01-21 14:12 晴明桑 阅读(113) 评论(0) 推荐(0)
摘要:数组判断: a instanceof Array //true Array.isArray(a) //true isArray(a) //true function isArray(e) { return Object.prototype.toString.call(e) '[object Arra 阅读全文
posted @ 2016-01-14 18:23 晴明桑 阅读(160) 评论(0) 推荐(0)
摘要://增加方法String.prototype.myNewMethod = function(){ return this.toUpperCase();} ;"abc".myNewMethod(); //匹配成对的括号function isBalanced(string){ var count = 0 阅读全文
posted @ 2016-01-11 13:56 晴明桑 阅读(181) 评论(0) 推荐(0)
摘要:1 function hasMethod(object,property){2 var a = typeof object[property];3 return a == 'function' || 4 ... 阅读全文
posted @ 2016-01-07 11:44 晴明桑 阅读(134) 评论(0) 推荐(0)
摘要:var pageWidth = window.innerWidth, pageHeight = window.innerHeight; if (typeof pageWidth != "number"){ ... 阅读全文
posted @ 2016-01-04 18:19 晴明桑 阅读(250) 评论(0) 推荐(0)

上一页 1 ··· 8 9 10 11 12