This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function retrieve(what) { | |
var currEl = what; | |
var args = Array.prototype.slice.call(arguments, 1); | |
while (args.length && currEl !== void 0 && currEl !== null) { | |
currEl = currEl[args.shift()]; | |
} | |
return currEl; | |
} | |
var x = retrieve(result, 'a', 'b', 'c') || retrieve(result, 'x', 'y') || retrieve(result, 0, 'a', n, 'x') || "lol"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bigArray = createBigArray(500000); | |
var maxPerTick = 200; | |
setTimeout(function notWow() { | |
var n = maxPerTick; | |
var el; | |
var currIndex = bigArray.length; | |
while (bigArray.length && n--) { | |
el = bigArray[currIndex--]; | |
process(el); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bigArray = createBigArray(500000); | |
var maxPerTick = 200; | |
setTimeout(function notWow() { | |
var n = maxPerTick; | |
var el; | |
while (bigArray.length && n--) { | |
el = bigArray[--bigArray.length]; | |
process(el); | |
} | |
setTimeout(notWow, 100); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = [1,2,3,4] | |
(function ajax(arr){ | |
if(!arr.length) return; | |
var tmp = arr.shift(); | |
setTimeout(ajax, 1000, arr); | |
console.log('wykonuje ajaxa '+tmp); | |
})(arr); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function clone(obj, callback) { | |
var from = window.location.origin; | |
var wrapper = {'__clone__': true}; | |
wrapper.__data__ = obj; | |
var listener = function(e) { | |
if(e.origin === from && e.data.__clone__) { | |
callback(e.data.__data__); | |
window.removeEventListener('message', listener); | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Klasa - plan lekcji. | |
function LessionPlan() { | |
// właściwość obiektu - _table - będzie przechowywać plan lekcji | |
this._table = []; | |
// tworzymy tabelę tablic | |
for (var i = 0; i < 7; i++) { | |
this._table.push([]); | |
} | |
// właściwość obiektu - godziny zajęć | |
this._hours = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title> | |
Noninvasive debugger statement | |
</title> | |
<style> | |
textarea { | |
width: 600px; | |
height: 500px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tokens.map(function(el, i, arr) { | |
var nextEl = arr[i + 1]; // get next element in array | |
if (nextEl != null && nextEl.constructor === el.constructor && el.by !== undefined) { | |
nextEl.by += el.by; | |
el.toRemove = true; // mark items to remove | |
} | |
return el; | |
}).filter(function(el) { | |
return !el.toRemove; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.defineProperty(Element.prototype, 'innerHTML', Object.create(Object.getOwnPropertyDescriptor(Element.prototype, 'innerHTML'), {get: function() {throw new Error;}})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function a(opt) { | |
opt = 3+opt; | |
return opt+1; | |
} | |
function b(opt) { | |
'use strict'; | |
opt = 3+opt; | |
return opt+1; | |
} |
OlderNewer