Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #38772
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Arno Welzel <usenet@arnowelzel.de> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: Drop off an if evaluation? |
| Date | Fri, 11 Sep 2020 09:05:05 +0200 |
| Lines | 35 |
| Message-ID | <hs0lt0F8p2hU1@mid.individual.net> (permalink) |
| References | <7b1b8132-4b87-4447-b31e-33d542b0529co@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | individual.net iY80A6RjF3hC/Fpnz+yDUw2088/fQPGcJTpifuyC33ufI9a0Yt |
| Cancel-Lock | sha1:F06ctc9oR1goZ+BptSilqZ6Rdd8= |
| In-Reply-To | <7b1b8132-4b87-4447-b31e-33d542b0529co@googlegroups.com> |
| Xref | csiph.com comp.lang.javascript:38772 |
Show key headers only | View raw
Jonas Thörnvall:
> Is there ways to code so that things that will only be true once, never checked again?
>
> The check dissapear?
Maybe something like this:
var mycheck = function(x) {
console.log('Check still executed');
if(x == true) {
mycheck = function(x) {
console.log('Not checking any longer');
return 1;
}
return 1;
} else {
return 2;
}
}
console.log('Run 1 with false');mycheck(false);
console.log('Run 2 with true');mycheck(true);
console.log('Run 3 with false');mycheck(false);
console.log('Run 4 with true');mycheck(true);
console.log('Run 5 with false');mycheck(false);
console.log('Run 6 with true');mycheck(true);
As soon as mycheck() is called with true as parameter, it replaces
itself with another function which will not do any check any more.
--
Arno Welzel
https://arnowelzel.de
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Drop off an if evaluation? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-10 23:45 -0700
Re: Drop off an if evaluation? Arno Welzel <usenet@arnowelzel.de> - 2020-09-11 09:05 +0200
Re: Drop off an if evaluation? Julio Di Egidio <julio@diegidio.name> - 2020-09-11 03:33 -0700
Re: Drop off an if evaluation? Julio Di Egidio <julio@diegidio.name> - 2020-09-11 07:01 -0700
Re: Drop off an if evaluation? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-09-11 18:20 +0200
Re: Drop off an if evaluation? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-11 10:05 -0700
Re: Drop off an if evaluation? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-11 10:19 -0700
Re: Drop off an if evaluation? Julio Di Egidio <julio@diegidio.name> - 2020-09-11 11:20 -0700
Re: Drop off an if evaluation? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-11 11:43 -0700
Re: Drop off an if evaluation? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-11 12:18 -0700
Re: Drop off an if evaluation? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-11 14:28 -0700
Re: Drop off an if evaluation? luserdroog <luser.droog@gmail.com> - 2020-09-12 20:59 -0700
Re: Drop off an if evaluation? luserdroog <luser.droog@gmail.com> - 2020-09-12 21:49 -0700
Re: Drop off an if evaluation? luserdroog <luser.droog@gmail.com> - 2020-09-12 23:15 -0700
Re: Drop off an if evaluation? John G Harris <niam@jghnorth.org.uk.invalid> - 2020-09-13 11:13 +0100
Re: Drop off an if evaluation? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-13 04:00 -0700
Re: Drop off an if evaluation? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-13 04:09 -0700
Re: Drop off an if evaluation? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-13 04:47 -0700
Re: Drop off an if evaluation? luserdroog <luser.droog@gmail.com> - 2020-09-13 22:56 -0700
Re: Drop off an if evaluation? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-14 08:22 -0700
Re: Drop off an if evaluation? luserdroog <luser.droog@gmail.com> - 2020-09-14 10:55 -0700
Re: Drop off an if evaluation? Jonas Thörnvall <jonas.thornvall@gmail.com> - 2020-09-14 14:47 -0700
csiph-web