Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #31555
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: How to have multiple and undetermined number of arguments for function? |
| Date | 2016-10-10 18:22 +0100 |
| Organization | PointedEars Software (PES) |
| Message-ID | <9018847.nUPlyArG6x@PointedEars.de> (permalink) |
| References | (6 earlier) <7112eabe-6254-4ac4-b2f2-ff9d3d6cff5e@googlegroups.com> <f50fbc4b-55b1-4e66-8745-e20fba0b54d8@googlegroups.com> <ntgbvb$5e0$1@dont-email.me> <718ec6b6-a194-48b3-87b9-3330b2f485d1@googlegroups.com> <ntgh20$p79$1@dont-email.me> |
Jake Jarvis wrote:
> Am 10.10.2016 um 17:50 schrieb justaguy:
>> […]
>> I see. Thought, indexOf is sort of "contains". In the meantime, I have
>> another statement, if (arguments[counter][0].indexOf('_row2')) {
>> // do this an that
>> }
>> and it found it. How come?
>
> You need to look a bit closer, something is being done to the result of
> indexOf.
> The ! operator is applied to it.
>
> indexOf just returns -1 or position inside the string
>
> For what numbers that indexOf might return does ! give a true?
> For a 0
(I stand) correct(ed). But now they have omitted the “!” operator,
reversing the condition, so the block will be executed whenever the element
either does not contain or does not start with "_row2".
IOW, the proper way to do this is
if (arguments[counter][0].indexOf("_row2") > -1)
{
/* do things if first element contains "_row2" */
}
or
if (arguments[counter][0].indexOf("_row2") >= 0)
{
/* do things if first element contains "_row2" */
}
if arguments[counter] is a reference to an array-like object.
--
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to have multiple and undetermined number of arguments for function? justaguy <lichunshen84@gmail.com> - 2016-10-08 14:48 -0700
Re: How to have multiple and undetermined number of arguments for function? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-10-09 00:07 +0200
Re: How to have multiple and undetermined number of arguments for function? justaguy <lichunshen84@gmail.com> - 2016-10-08 16:03 -0700
Re: How to have multiple and undetermined number of arguments for function? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-10-09 09:59 +0200
Re: How to have multiple and undetermined number of arguments for function? John Harris <niam@jghnorth.org.uk.invalid> - 2016-10-09 15:35 +0100
Re: How to have multiple and undetermined number of arguments for function? justaguy <lichunshen84@gmail.com> - 2016-10-09 11:22 -0700
Re: How to have multiple and undetermined number of arguments for function? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-10-09 20:09 +0100
Re: How to have multiple and undetermined number of arguments for function? justaguy <lichunshen84@gmail.com> - 2016-10-09 13:32 -0700
Re: How to have multiple and undetermined number of arguments for function? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-10-09 23:26 +0200
Re: How to have multiple and undetermined number of arguments for function? justaguy <lichunshen84@gmail.com> - 2016-10-09 15:18 -0700
Re: How to have multiple and undetermined number of arguments for function? justaguy <lichunshen84@gmail.com> - 2016-10-10 07:57 -0700
Re: How to have multiple and undetermined number of arguments for function? Jake Jarvis <pig_in_shoes@yahoo.com> - 2016-10-10 17:26 +0200
Re: How to have multiple and undetermined number of arguments for function? justaguy <lichunshen84@gmail.com> - 2016-10-10 08:50 -0700
Re: How to have multiple and undetermined number of arguments for function? Jake Jarvis <pig_in_shoes@yahoo.com> - 2016-10-10 18:53 +0200
Re: How to have multiple and undetermined number of arguments for function? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-10-10 18:22 +0100
Re: How to have multiple and undetermined number of arguments for function? justaguy <lichunshen84@gmail.com> - 2016-10-10 11:20 -0700
Re: How to have multiple and undetermined number of arguments for function? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-10-10 17:28 +0100
Re: How to have multiple and undetermined number of arguments for function? justaguy <lichunshen84@gmail.com> - 2016-10-09 11:20 -0700
Re: How to have multiple and undetermined number of arguments for function? justaguy <lichunshen84@gmail.com> - 2016-10-09 12:10 -0700
Re: How to have multiple and undetermined number of arguments for function? justaguy <lichunshen84@gmail.com> - 2016-10-10 17:05 -0700
csiph-web