Ondřej Žára, Seznam.cz
if (!Date.now) Date.now = function() { return +new Date; }
$("...sračky...")
node.querySelector("#result .item")
node.querySelectorAll(":hover")
node.classList.add("active")
node.classList.contains("active")
node.classList.toggle("active")
node.addEventListener("click", ...)
var data = [....];
var filtered = data.filter(function(item) {
return item.x == y;
});
String.prototype.trim()
Object.create()
Function.prototype.bind()
Object.create = function(parent) {
var tmp = function() {};
tmp.prototype = parent;
return new tmp();
}
var Parent = function() {};
Parent.prototype.doStuff = function() { /* ... */ }
var Child = function() {};
Child.prototype = Object.create(Parent.prototype);
Function.prototype.bind = function(context) {
var func = this;
return function() {
return func.apply(context, arguments);
}
}
var Animal = function() {}
var a = new Animal();
setTimeout(a.eat.bind(a), 1000);
Function.prototype.bind = function(context) {
var func = this;
var args1 = Array.prototype.slice.call(arguments, 1);
return function() {
var args2 = Array.prototype.slice.call(arguments);
return fn.apply(context, args1.concat(args2));
}
}
Prostor pro otázky
Ondřej Žára, Vývojář UI, ondrej.zara@firma.seznam.cz