Last active
August 29, 2015 14:27
-
-
Save ZiTAL/58c6017e6490a290001f to your computer and use it in GitHub Desktop.
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
// array guztiari funtzio bera aplikatzeko erabiliko dugu | |
var zenbakiak = [1, 2, 3]; | |
// funtzioak parametro moduan array-aren balorea hartzen du (i) | |
var erantzuna = zenbakiak.map(function(i) | |
{ | |
return i+1; | |
}); | |
console.log(erantzuna); | |
// [ 2, 3, 4 ] | |
var zenbakiak = [1, 2, 3]; | |
// funtzioak parametro moduan array-aren balorea hartzen du (i) | |
var erantzuna = zenbakiak.map(function(i) | |
{ | |
return { | |
"i": i | |
} | |
}); | |
console.log(erantzuna); | |
/* | |
[ | |
{ | |
i: 1 | |
}, | |
{ | |
i: 2 | |
}, | |
{ | |
i: 3 | |
} | |
] | |
*/ | |
var zenbakiak = [1,2,3]; | |
var erantzuna = zenbakiak.map(random); | |
function random() | |
{ | |
return Math.random(); | |
} | |
console.log(erantzuna); | |
// [ 0.990556649165228, 0.942918487591669, 0.23707670415751636 ] | |
var zenbakiak = [1,2,3]; | |
var erantzuna = zenbakiak.map(gehi); | |
// funtzioak parametro moduan array-aren balorea hartzen du (i) | |
function gehi(i) | |
{ | |
return i+Math.random(); | |
} | |
console.log(erantzuna); | |
// [ 1.727500163251534, 2.09510179143399, 3.7634155368432403 ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment