Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Jake Jarvis Newsgroups: comp.lang.javascript Subject: Re: setInterval Date: Tue, 7 Feb 2017 11:13:47 +0100 Organization: A noiseless patient Spider Lines: 89 Message-ID: References: <6cb902b0-8913-4b65-954d-5d9f0e60ee95@googlegroups.com> <4cbfae02-e217-436d-8c41-004de444915c@googlegroups.com> <8e741582-e2a8-4713-b49d-6bd5a50a8317@googlegroups.com> <87h947e7f5.fsf@bsb.me.uk> <82f4ba9f-8d80-4769-842a-5a9b066efb5a@googlegroups.com> <5898e78d$0$18070$e4fe514c@newszilla.xs4all.nl> <3141f801-2946-40fc-87ad-97668f7061e4@googlegroups.com> <4dcf7316-29b0-4506-a14c-48c4ed827c18@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Tue, 7 Feb 2017 10:12:01 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="b69d114732353a0b876e670324e98904"; logging-data="15884"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/UhQzsdCV/4/3t0poZweLOlPddkAlyA38=" User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 In-Reply-To: <4dcf7316-29b0-4506-a14c-48c4ed827c18@googlegroups.com> Cancel-Lock: sha1:RNLzc5L1r/8ZmGRoUzqSK6E89M0= Xref: csiph.com comp.lang.javascript:32537 Am 07.02.2017 um 07:45 schrieb jonas.thornvall@gmail.com: > Den tisdag 7 februari 2017 kl. 07:27:43 UTC+1 skrev Julio Di Egidio: >> On Tuesday, February 7, 2017 at 7:09:59 AM UTC+1, jonas.t...@gmail.com wrote: >>> Den tisdag 7 februari 2017 kl. 06:22:34 UTC+1 skrev Julio Di Egidio: >> >>> Well i solved it, but i really hate when i can't ***understand*** the >>> difference, but one approach work. >> >> Have you tried *studying* the language? I have given few essential pointers. >> >>> So i would be glad if someone can tell why this is correct and work, while >>> all other *equivalent*? fails miserable. >> >> Because they were not equivalent... One thing I notice is that in this one you >> are using setInterval, not setTimeout, and you just happen to have put together >> some working scheme. >> >> Something I can tell you for sure is that you'll be banging your head on the >> table for as long as your approach to programming is that of the trial and >> error... >> >> Best luck and have fun, >> >> Julio >> >>> function INTRO(){ >>> mycount=25; >>> document.NoLinks.linkval.value=mycount; >>> document.getElementById('mysubset').selectedIndex=1; >>> bananas=setInterval(function(){monkeybuisness();}, 200); >>> } >>> >>> function monkeybuisness() { >>> mycount--; >>> document.NoLinks.linkval.value=mycount; >>> AUTOGRAPH(); >>> if(mycount<1){clearInterval(bananas);document.getElementById('mysubset').selectedIndex=0;} >>> } > > Well if you know their not equvalent, why are they not equvalen, i see this one use > bananas=setInterval(function(){monkeybuisness();}, 200); > > what differ when execute upper from lower example > > bananas=setInterval(monkeybuisness();, 200); > > Because i would think that the lower syntax is the straightforward to do what the upper actually, do just do not understand. > > So please explain to me. > 1. What does the lower one actually do, because it simply not working. > 2. What the fuck does the upper syntax mean, it is none sensical? > function(){monkeybuisness();}, 200???????????? What kind of fucking syntax is this, and where did ECMASCRIPT/JAVASCRIPT found the idea behind, because there must be one right? I do not feel comfortable just throwing in things that i can not see the purpose with. So please for god sake can someone explain what the syntax is about, or should i just except it is totally fucking nonesensible? > > You see for me the syntax could as well be to settimeout > setInterval(afewbananas(){monkeybuisness();}, 200) > And you see monkeybuisness i have no problem with alot of what i do is that. > But one wonder why should i always stick a few bananas into the monkey buisness. I know what monkey buisness do but i am fucking clueless to the mysteries of a few bananas. > > Ok rant finished, but if someone know the answer to a few bananas, don't hesitate to tell me. > You can do a couple of things with functions in this language: - you can call them - you could give it to someone else, so they call it (remember the FileReader?) Do you understand that? // calling monkeybusiness(); vs. /* giving setTimeout a handle on the function, setTimeout will arrange the calling ... after the timeout */ window.setTimeout(monkeybusiness, 1000); But also please understand how functions can be defined in this language. /* giving setTimeout a handle on an anonymous function that calls monkeybusiness, setTimeout will arrange the calling */ window.setTimeout(function(){monkeybusiness();}, 1000);