Nová ukázka
Reset
Načíst z URL
Uložit a získat odkaz
Vztahuje se k…
Nevyplňujte
Napiště „nejsem robot“
▶
Přepnout zobrazení
Výsledek
HTML
Autoformát
Standardní režim
Mobilní zobrazení
CSS
Autoformát
CSS reset
Až na konci
var positions = []; positions.push({x: 10, y: 10}); positions.push({x: 10, y: 11}); positions.push({x: 10, y: 12}); positions.push({x: 10, y: 13}); /** * Returns array of indexes where predicate is satisfied. */ function filter(pred, array) { var filtered = []; for (var i = 0; i < array.length; i++) { if (pred(array[i])) { filtered.push(i); } } return filtered; } /** * Returns predicate for coordinate equality testing. */ function coordsEqPred(c1) { return function(c2) { return c1.x == c2.x && c1.y == c2.y; }; } // definition of what we search for var needle = {x: 10, y: 11}; // where it was found var found = filter(coordsEqPred(needle), positions); alert(found);
J
ava
S
cript
Autoformát
jQuery
Umístění JS
window.onload
</head>
</body>