随笔分类 -  js

摘要:主要就是《javascript语言精粹》语言精粹中的内容5.1伪类Function.prototype.method = function(name,func){ this.prototype[name] = func; return this; }var Cat = function(name){ this.name = name; this.saying = "meow";}Cat.prototype = new Mammal();Cat.prototype.purr = function(n){ var i,s = ""; for(i = 0 ; 阅读全文
posted @ 2014-03-25 10:17 星堡a 阅读(1842) 评论(0) 推荐(0)
摘要:1.首先输入点击要能够有两个日历画出月份,大部分是5x7行,但是也会有6x7的情况(1号为周六)计算1号的位置,月份的清空,画月份时候,当日的判断。//画表格行数 var rows = Math.ceil((maxDay+first)/7); var beforeTable = '日一二三四五六'; var table; for(var i = 0 ; i " ; for( var j = 1 ; j "+ (j + 7 * i) +"" //周日就是1号的判断 table += "... 阅读全文
posted @ 2014-03-21 11:36 星堡a 阅读(236) 评论(0) 推荐(0)
摘要:《javascript语言精粹》中的var is_array = function(value){ return value && //判断值是否为真,不接受null和其他为假的值 typeof value === "object" && //对象、数组和(古怪的)null 为true typeof value.length === "number" && //对象不为null typeof value.splice ... 阅读全文
posted @ 2014-03-11 15:40 星堡a 阅读(143) 评论(0) 推荐(0)
摘要:题目是群中小伙伴出的。var a = [1,2,3]; c= a//todo 限制条件 c 不能出现在 = 左边console.log(a)console.log(c)console.log(a === c)在todo中写段代码 执行[][]true我想到的答案1. a.length = 02. 群中其他人的答案 a.splice(0,a.length)想到的错误办法:1. a = [] //因为array是引用类型,a = [] ,只是指向一个新的array,c还是指向老的array2. for(var i = 0 ; i < a.length ; i ++){delete a[i]} 阅读全文
posted @ 2014-02-21 16:38 星堡a 阅读(238) 评论(0) 推荐(0)
摘要:代码转自 codewars:http://www.codewars.com/var data = { id: 1, items: [ {id: 2}, {id: 3, items: [ {id: 4}, {id: 5} ]} ]}function extractIds(data){ var arr = []; if(data.id){ arr.push(data.id); } if(data.items){ for(var i in data.items){ var subData = extractIds(data... 阅读全文
posted @ 2014-01-22 18:05 星堡a 阅读(135) 评论(0) 推荐(0)
摘要:console.log在不同的地方也会导致不同 2018年4月18日更新: 第一题: 第二题: 第三题: 第二题中如何得5? (答案在最下面) 再看一个类似的:看不太懂二者之间的区别 a和foo.bar.baz() 假期在家,看到的,昨天看了下; 原文链接:http://wwwcqamin.duap 阅读全文
posted @ 2013-10-08 12:37 星堡a 阅读(385) 评论(0) 推荐(0)
摘要://如何获取下面代码所有元素、 var form = document.forms[0];for(var i = 0 ; i添加个事件var alink = document.getElementById("aa");alink.addEventListener("click",function(){alert("della")}); //ie8下都不能用 阅读全文
posted @ 2013-09-02 18:24 星堡a 阅读(88) 评论(0) 推荐(0)
摘要:jQuery outerWidth(true)支持ie7 不错不错css BFC a {display:inline-block} 有用,block不是很有效果 a{ display:inline-block; margin-bottom:30px; margin-top:30px; overflow:hidden}css3 text-justify: inter-ideograph ie8下有用,chrome下没有用html5 link prefetching 在做手机项目中css(viewport 具体叫什么?控制屏幕大小)width – viewport的宽度height – view. 阅读全文
posted @ 2013-09-02 15:27 星堡a 阅读(293) 评论(0) 推荐(0)