Closure multiplate call function im javascript -
example write down
myfunc('asdas')
it's console.log me
'asdas'
then after write down
myfunc('as')('ds')('ko')....('other')
function must console.log me
"as ds ko .... other"
i tried realize have many problems it.
function me (str){ //var temp = str; return function mes(val) { val += ' '+ str; console.log(val); //return mes; } }
how correctly realize function?
well, bit funny, works:
concat = function(x, val) { val = (val || "") + x; var p = function(y) { return concat(y, val) }; p.tostring = function() { return val }; return p } x = concat('a')('b')('c')('d'); document.write(x)
Comments
Post a Comment