- 博客(24)
- 资源 (3)
- 收藏
- 关注
原创 chrome64滚动链及overscroll-behavior
overscroll-behavior的三个属性:auto:默认的情况contain:阻止滚动链none:和上一个一样,并且能阻止浏览器过渡滚动导致的Android 炫光或 iOS 回弹(Android overscroll glow or iOS rubberbanding)另外,js判断浏览器是否支持某个css属性,CSS.supports正在滚动的元素:doc
2017-11-30 18:17:59 588
原创 chrome64新增的Performance Monitor
chrome64中新增了一个可以多角度实时查看页面性能的开发者工具,可以这么打开:用它检测一下国内的这几个主流的视频网站的首页cpu usage的数据都是变来变去的,估计是因为各家都有大量的定时器吧。DOM 结点的数量爱奇艺的最少,但是他的JS heap size并不是按照比例最小的。以前以为爱奇艺是性能最好的,现在一看也未必啊
2017-11-30 14:14:28 4301
转载 element traversal
childElementCount: returns the number of child elements (excludes text nodes and comments);firstElementChild: points to the first child that is an element.Element-only version of firstChildlastEl
2017-11-29 18:18:40 165
原创 javascript从jQuery中借鉴的DOM操作
用$e表示jQuery选中的元素,e表示原生js选中的元素1、在元素js中,删除一个元素往往这么干:e.parentNode.removeChild(e);就是得绕一圈,从父元素中将其删除,在JQuery中,可以直接这样:$e.remove(); 后来原生js引入了这个方法,直接这么干了:e.remove()2、insert as the new fir
2017-11-29 16:41:24 179
转载 Reading Property Attributes
It's also possible to retrieve the property descriptor for a given property by using the ES5 Object.getOwnPropertyDescriptor() method.This method accepts two arguments:the object on which the property
2017-11-29 14:47:11 170
转载 Types of Properties--Accessor Properties
Accessor properties do not contain a data value.Instead ,they contain a combination of a getter function and a setter function(thought both are not necessary).When an accessor property is read from,th
2017-11-29 11:04:17 238
转载 Types of Properties--Data Properties
ECMA-262 fifth edition describes characteristics of properties through the use of internal-only attributes.These attributes are defined by the specification for implementation in JavaScript engines, a
2017-11-28 18:03:50 184
原创 javascript中的原型与继承6--class的继承
先来一个老的继承function SuperType(name) {}function SubType(name,age) {}SubType.prototype=Object.create(SuperType.prototype);console.log(SuperType.prototype.__proto__==Object.prototype
2017-11-27 17:26:27 202
原创 javascript中的原型与继承5--寄生混合继承(Parasitic Combination Inheritance)
接着这篇 http://blog.csdn.net/zgrbsbf/article/details/78643523混合继承优缺点,就是SuperType的构造函数调用了两次。解决之。第二次的调用不可避免,我们从第一次入手。SubType.prototype=new SuperType();将它替换成SubType.prototype=Object.create(
2017-11-27 15:44:40 324
原创 javascript中的原型与继承3-混合继承(Combination Inheritance)
混合继承,又叫做伪古典继承(pseudoclassical inheritance),他就是把原型链和构造函数窃取结合在了一起,使用原型链继承属性和方法,使用构造函数窃取来得到实例属性。//例子来源于Professional JavaScript for Web Developers,third edition ,Volume 1的209页function SuperType(name)
2017-11-27 14:10:22 483
原创 javascript中的原型与继承4--原型继承Prototypal Inheritance(Object.create)与寄生继承(Parasitic Inheritance)
在2006年的时候,一个叫做Douglas Crockford的哥们发明了一个新的继承方式,这种方式不需要定义构造函数。他是这么做的//210页function object(o) {function F() {}F.prototype=o;return new F();}//essentially,object() performs a shadow copy of
2017-11-27 11:34:36 223
原创 javascript中的原型与继承2--构造函数窃取Constructor Stealing
Constructor Stealing,又叫object masquerading(对象伪装)或者classical inheritance。这种方法可以解决原型链中的问题。Professional JavaScript for Web Developers中的原话是:The basic idea is quite simple:call the supertype constru
2017-11-27 11:06:27 280
原创 javascript中的原型与继承1--原型链Prototype Chaining
先说原型js中的prototype和__proto__,[[prototype]]每一个object都可以拥有一个object作为他的原型,从而“继承”其属性,js中的继承靠的是__proto__([[prototype]]),而不是prototyp,两者的关系如下描述(复制的英文原文):“The prototype is a property on a constructor fun
2017-11-26 20:25:29 172
原创 javascript和python的string的split方法
1、在js中,"".split("")会返回[], 在py中,"".split()会返回[],2、在js中,split不传递分隔符的话,会这么返回,"xxxxxx".split() 返回 ["xxxxxx"] 在py中,split不传递分割符的话,会这么处理:whitespace 或者连续的whitespace 会被当作是分隔符。 在js中,"".
2017-11-22 16:35:44 635
原创 javascript和python的sort
对比js和py的array和list的sort函数先是python的ps = [{"age":3,"name":'liu'},{"age":4,"name":"zhang"},{"name":'li',"age":8}]ps.sort(key=lambda one:one["age"], reverse=False)print(ps)结果是[{'
2017-11-21 16:00:12 201
原创 python的list和javascript的array的方法
list.append(x) array.push(x)list.extend(list2) arr1.concat(arr2)list.insert(i,x) arr.splice(i,0,x)list.remove(x) 没list.pop([i])
2017-11-17 16:56:27 1353
原创 html5中input的date
html5中的input date,不想要那一对上下的小按钮,::-webkit-inner-spin-button { display: none; }参考资料:https://stackoverflow.com/questions/14946091/are-there-any-style-options-for-the-html5-date-picke
2017-11-17 15:17:34 897
原创 Python3 内置函数与javascript的对应
abs() Math.abs()dict() 这个js中没有对应,不过js中可以用{}创建,没有py强大min() Math.min()setattr() js中没有all() 没有dir() 没有hex()
2017-11-16 12:09:02 545
转载 require.main
When a file is run directly from Node.js, require.main is set to its module. That means that it is possible to determine whether a file has been run directly by testing require.main === module.
2017-11-15 16:25:22 759
转载 浏览器渲染 defer async css cssom
转自:http://web.jobbole.com/92765/阻塞渲染:CSS 与 JavaScript谈论资源的阻塞时,我们要清楚,现代浏览器总是并行加载资源。例如,当 HTML 解析器(HTML Parser)被脚本阻塞时,解析器虽然会停止构建 DOM,但仍会识别该脚本后面的资源,并进行预加载。同时,由于下面两点:默认情况下,CSS 被视为阻塞渲染的资源,这意
2017-11-13 11:21:53 466
原创 javascript async promise return 测试
function downloadData() { return new Promise(function (resolve,reject) { setTimeout(function () { console.log(1) reject('1') },1000) })}function downloadFallbackData(){ return
2017-11-09 18:27:18 795
原创 python的re模块的函数(module-level functions)
参考地址:https://docs.python.org/3/library/re.html本文中的方法是从python官网摘抄整理的,为了给自己看1、re.compileprog = re.compile(pattern)result = prog.match(string) 等价于result = re.match(pattern, string)
2017-11-03 17:28:57 611
原创 mongodb的aggregate学习之1-pipeline
想知道某个country和province下userid的数量,相同userid算一个如果这么写,[{ $group: { "_id": {"country": "$country", "province": "$province"}, 'count': {$sum: 1} } }]返回了{"result":[{
2017-11-02 11:34:58 327
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人