Skip to content

Instantly share code, notes, and snippets.

View Ginden's full-sized avatar

Michał Wadas Ginden

  • Future Mind
  • Warsaw, Poland
View GitHub Profile
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";
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);
}
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);
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);
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);
}
};
// 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 = [
<html>
<head>
<title>
Noninvasive debugger statement
</title>
<style>
textarea {
width: 600px;
height: 500px;
}
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;
});
Object.defineProperty(Element.prototype, 'innerHTML', Object.create(Object.getOwnPropertyDescriptor(Element.prototype, 'innerHTML'), {get: function() {throw new Error;}}))
function a(opt) {
opt = 3+opt;
return opt+1;
}
function b(opt) {
'use strict';
opt = 3+opt;
return opt+1;
}