That only works if all values are distinct. The following will result
in the wrong index for the last item:
let values = ["a", "b", "a"];
for (let value of values) {
let index = values.indexOf(value);
}
Also that construct is not very performant.
Sebastian
On 15 July 2015 at 03:02, Rick Wal
Thanks for all the suggestion. I think since not many languages supports
this it would be very hard to convince you.
I think I can live with the `for (let [index, value] of arr.entries()) {}`
solution.
One
ons 15 juli 2015 kl 09:02 skrev Rick Waldron :
> If you need the _index of_ a value in an
If you need the _index of_ a value in an array, there is always...
"indexOf" ;)
for (let value of values) {
let index = values.indexOf(value);
}
Rick
On Tue, Jul 14, 2015 at 4:16 PM Tab Atkins Jr. wrote:
> On Mon, Jul 13, 2015 at 7:13 PM, Tingan Ho wrote:
> > Just following a discussion we
Hi all,
Not sure how to start it, so posting here, please correct me if it's misuse
of this list.
I've looked into a threads of the last year and didn't find any discussion
regarding deep Object.observe feature (as well as something like
setPath/getPath functionality), and would like to raise it a
On Mon, Jul 13, 2015 at 7:13 PM, Tingan Ho wrote:
> Just following a discussion we had on TypeScript
> https://github.com/Microsoft/TypeScript/issues/3835
>
> In most times, I just need the value in an array, so I use a for..of loop.
> But then, I find out that I need the index too, then I need to
And --- apologies for continuing to beat this drum --- you can look at the
`prfun` package on npm for a practical example of this use of Promise
subclasses and `resolve`.
If other folks know of other libraries using these features, let me know so
I can recommend other people's code as well as my o
Hi,
And it's called zipWithIndex in Scala:
```scala
for ((value, i) <- someTraversable.zipWithIndex) {
// do stuff
}
```
And, in Ruby, it's each_with_index:
```ruby
for value, i in someArray.each_with_index
# do stuff
end
```
I see a pattern, here. It seems several other languages are pret
It's called `enumerate` in Python. And it's trivial to implement:
```js
for (let [i, value] of enumerate(someIterable)) {
// behold...
}
```
On Tuesday, July 14, 2015, Domenic Denicola wrote:
> From: Tingan Ho [mailto:tinga...@gmail.com ]
>
> > But they aren't clean solutions to a wildly pop
Awesome, thank you!
-N
On 7/14/2015 10:12 AM, Domenic Denicola wrote:
Yes.
On Tue, Jul 14, 2015 at 10:10 AM -0700, "Nicholas C. Zakas"
mailto:standa...@nczconsulting.com>> wrote:
Hi all,
I'm trying to wrap my head around derived promises and wanted to ask for
a bit of clarification aro
Yes.
On Tue, Jul 14, 2015 at 10:10 AM -0700, "Nicholas C. Zakas"
mailto:standa...@nczconsulting.com>> wrote:
Hi all,
I'm trying to wrap my head around derived promises and wanted to ask for
a bit of clarification around how `Promise.resolve()` works from a
derived class. Consider this:
```
c
Hi all,
I'm trying to wrap my head around derived promises and wanted to ask for
a bit of clarification around how `Promise.resolve()` works from a
derived class. Consider this:
```
class MyPromise extends Promise {}
var p1 = new Promise(function(resolve, reject) {
resolve(42);
});
var
On Tue, Jul 14, 2015 at 10:59 AM, Andreas Rossberg
wrote:
> On 14 July 2015 at 16:48, Mark S. Miller wrote:
>
>> On Tue, Jul 14, 2015 at 2:31 AM, Andreas Rossberg
>> wrote:
>>
>>> I don't see why you need parens at all, see my previous post. But I
>>> wouldn't make the do-less forms the base sy
On 14 July 2015 at 16:48, Mark S. Miller wrote:
> On Tue, Jul 14, 2015 at 2:31 AM, Andreas Rossberg
> wrote:
>
>> I don't see why you need parens at all, see my previous post. But I
>> wouldn't make the do-less forms the base syntax,; rather, only short-hands
>> for the general thing. In particu
From: Tingan Ho [mailto:tinga...@gmail.com]
> But they aren't clean solutions to a wildly popular problem.
I disagree.
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
>This is pretty ingenious. If I thought this was a real problem that needed
solving
I'm not sure how I should interpret this. But I'm pretty sure you also need
the current index of array in a for loop.
Since I can access the index and value directly in `.forEach(value, index,
array)`, why isn't t
On Tue, Jul 14, 2015 at 2:31 AM, Andreas Rossberg
wrote:
> I don't see why you need parens at all, see my previous post. But I
> wouldn't make the do-less forms the base syntax,; rather, only short-hands
> for the general thing. In particular, because the ability to have an actual
> block inside
On 14 July 2015 at 15:41, Jonathan Bond-Caron
wrote:
> On Tue Jul 14 09:27 AM, Domenic Denicola wrote:
> > From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of
> > Matthew
> > Robb
> >
> > > Why not use the new meta syntax?
> >
> > If I thought this was a real problem that
> > ne
On 14 July 2015 at 15:04, Matthew Robb wrote:
> The only gripes I have with do expressions is the inability to specify the
> value produced in an obvious and uniform way,
>
Well, the completion value is fairly uniform. You mean an analogue to a
return in a function body?
> also are do expressi
On Tue Jul 14 09:27 AM, Domenic Denicola wrote:
> From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of
> Matthew
> Robb
>
> > Why not use the new meta syntax?
>
> If I thought this was a real problem that
> needed solving,
Disagree
"As early as the mid-1980’s, it was observed t
From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of Matthew
Robb
> Why not use the new meta syntax?
This is pretty ingenious. If I thought this was a real problem that needed
solving, I'd definitely go this route. (But, I think that using .entries() and
destructuring is fine,
Why not use the new meta syntax?
for (let value of values) {
console.log(for.index);
}
- Matthew Robb
On Tue, Jul 14, 2015 at 7:45 AM, Jonathan Bond-Caron <
jbo...@gdesolutions.com> wrote:
> On Mon Jul 13 10:22 PM, Kevin Smith wrote:
>
> > Destructuring is here to help:
> >
> > for (let
The only gripes I have with do expressions is the inability to specify the
value produced in an obvious and uniform way, also are do expressions
capable of being labelled?
- Matthew Robb
On Tue, Jul 14, 2015 at 3:31 AM, Andreas Rossberg
wrote:
> I don't see why you need parens at all, see my p
There are a couple of people tossing around named parameter ideas that have
different identifiers than the argument identifier. What is wrong with what
Gary Guo originally said with `foo(bar: 5)`, it uses `:` for mapping
similar to an object literal, but does not require having contextual
knowledge
On Mon Jul 13 10:22 PM, Kevin Smith wrote:
> Destructuring is here to help:
>
> for (let [index, value] of [1, 2, 3].entries())
> console.log(index + ": " + value)
>
> The "entries" method returns an iterator of [index, value] pairs.
>
Can't there be a 'key iterator' syntax?
for
Seems everybody is pessimistic about this. But using optional `labels`
would solve any problem with the minifiers.
```javascript
// Not minified (Labels are optional, default are the variable names)
function foo (bar = 1, baz = 2, bak = 3) {
console.log(baz);
}
foo (baz: 2);
// Minified
function f
I don't see why you need parens at all, see my previous post. But I
wouldn't make the do-less forms the base syntax,; rather, only short-hands
for the general thing. In particular, because the ability to have an actual
block inside an expression is one primary motivation for having
do-expressions i
All you are proposing is to allow the braces to be dropped from a
do-expression, right? That's an obvious tweak, although I'm not sure if it
really improves readability. (Other than that, do-expressions are already
intended to work as you describe, using the completion value of the
statement list.
27 matches
Mail list logo