Re: Providing object iterators beyond just Object.keys()

2015-05-27 Thread Emanuel Allen
You can simply use the Symbol.iterator property to configure how you want the 
property and value of the object to be iterated. This will allow you to use any 
from of iteration; e.g. For loop while loop forEach if you do the generic way 
I'm thinking .

If this help. Post me some link to resources that you have found on your 
journey as a js dev.

JS4Lf

> On May 27, 2015, at 9:47 AM, Rick Waldron  wrote:
> 
> No draft written, but I am the current champion. If you'd like to get 
> something started, we can co-champion :)
> 
> Rick
>> On Tue, May 26, 2015 at 2:45 PM Michael Ficarra  
>> wrote:
>> Has anyone drafted a proposal for this? Is anyone assigned as champion yet?
>> 
>>> On Tue, May 26, 2015 at 11:05 AM, Rick Waldron  
>>> wrote:
>>> Silence because it wasn't a priority, relative to finishing ES6. It's not 
>>> forgotten and still on track for ES7 development. 
>>> 
>>> Rick
 On Tue, May 26, 2015 at 11:59 AM Gijs Kruitbosch 
  wrote:
 Perhaps surprisingly, I had actually asked around and looked through 
 recent threads. Apologies for not having found the previous discussions 
 from a year ago. It seems that after the call for a strawman in the 
 meeting notes from April 2014, there was silence? 
 https://esdiscuss.org/topic/object-entries-in-2015 asks the same. I don't 
 really know whether it's more useful to continue replying here or pull up 
 that thread (is one month "old" by es-discuss standards?). Either way, it 
 would be useful to know what the current status is, which none of the 
 posts/notes that I saw really clarify.
 ___
 es-discuss mailing list
 es-discuss@mozilla.org
 https://mail.mozilla.org/listinfo/es-discuss
>>> 
>>> ___
>>> es-discuss mailing list
>>> es-discuss@mozilla.org
>>> https://mail.mozilla.org/listinfo/es-discuss
>> 
>> 
>> 
>> -- 
>> Shape Security is hiring outstanding individuals. Check us out at 
>> https://shapesecurity.com/jobs/
> ___
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Label statement moveable

2015-05-20 Thread Emanuel Allen
Yes:

> foo: {
> // ...
> if (bar)
> continue foo // (currently a SyntaxError)
> // ...
> }


in my first attempt at posting this I did something similar:

 function foo(v){
> 
>>>>  return v + 1;
>>>> }
>>>> 
>>>> 
>>>>  var i = 0;
>>>> 
>>>>  baz:{
>>>>i += 1;
>>>>  }
>>>> 
>>>> continue baz;//same as foo(i);
>>>> 
>>>> console.log(i);

But not that I want restriction on where continue can be use; only in block 
scope. Rather that's in an if/else else if statement or a function statement.


And another important thing is I want label statement reachable from the scope 
they are define.

So my first attempt example would actually be rewritten to:
var i;
foo:{
  if(typeof i!=='number') break;
  i+=1;
} 
I =0;
{
if (i < 5);
  continue foo;
}

console.log(i);//log 4

Again the true aim for this is to lower function calls. 


JS4Lf

> On May 20, 2015, at 11:56 AM, Claude Pache  wrote:
> 
> I occasionally (quite rarely) use the following variant of the classical 
> `do/while(false)` trick:
> 
> ``
> foo: do {
> // ...
> if (bar)
> continue foo // meaning: restart from foo
> // ...
> break 
> } while (true) // not a real loop, just a hack
> ```
> 
> Maybe the following syntax could be used?
> 
> ```
> foo: {
> // ...
> if (bar)
>     continue foo // (currently a SyntaxError)
> // ...
> }
> ```
> 
> WDYT?
> 
> —Claude
> 
> 
>> Le 20 mai 2015 à 12:45, Sebastian McKenzie  a écrit :
>> 
>> So you want to add goto to JavaScript?
>> 
>> 
>> 
>> 
>>> On Wed, May 20, 2015 at 11:42 AM, Emanuel Allen  
>>> wrote:
>>> Clarify:
>>> 
>>> My previous post was not that clear. That post display what I would like to 
>>> do in the language. Here is the actual code if I choose to do it as the 
>>> language is now: 
>>> var i = 0, n = 5;
>>> l2: do {
>>>  i += 1;
>>>  l3: do {
>>>if (i>>else break l3;
>>>  } while (true);
>>>  break l2;
>>> } while (true);
>>> //just log the value n+1:
>>> console.log('i:'+i);
>>> 
>>> loop through label l2 n amount of times before breaking.
>>> 
>>> This could be useful to escape function invocation cost, if it could be 
>>> simply express:
>>>  l2: {
>>>   i += 1;
>>>  }
>>>  l3: {
>>>if (i>>  }
>>> 
>>> The function way is to:
>>> function l2(){
>>>   i += 1;
>>> }
>>> 
>>> l3: do {
>>>if (i>>else break l3;
>>>  } while (true);
>>> 
>>> I did a http://jsperf.com/block-scope-vs-function-invocation";>
>>> jsprf to further my argument for a sudo goto/function effect:
>>> 
>>> http://jsperf.com/block-scope-vs-function-invocation
>>> 
>>> JS4Lf
>>> 
>>>> On May 19, 2015, at 2:45 PM, L4L  wrote:
>>>> 
>>>> Since we have block scope, and we have continue statement to which we can 
>>>> use in loops to jump back to the conduction statement part. 
>>>> 
>>>> Than can we consider making label stamens moveable by its name. 
>>>> 
>>>> I'll like to say that the side effect would be sudo(pseudo) function, 
>>>> example:
>>>> 
>>>> function foo(v){
>>>>  return v + 1;
>>>> }
>>>> 
>>>> 
>>>>  var i = 0;
>>>> 
>>>>  baz:{
>>>>i += 1;
>>>>  }
>>>> 
>>>> continue baz;//same as foo(i);
>>>> 
>>>> console.log(i);
>>>> 
>>>> Note that I said sudo function. Its mobility is what of value; depending 
>>>> on how JavaScript handle the continue statement in a loop to transport 
>>>> that effect out side a loop. 
>>>> 
>>>> Stripping this privilege to black scope; where the continue statement is 
>>>> expanded to work only in block scope and nested block scope; to where it 
>>>> can only jump to the beginning of that block or any other block scope that 
>>>> is scoped to that outer block scope but not nested block scope with in the 
>>>> scope... Like function.
>>>> 
>>>> Continue and break statement could be of more power; where we can avoid 
>>>> some function call in "speed matter" application.
>>>> 
>>>> Excuse any grammar errors. 
>>>> 
>>>> JS4Lf
>>>> ___
>>>> es-discuss mailing list
>>>> es-discuss@mozilla.org
>>>> https://mail.mozilla.org/listinfo/es-discuss
>> 
>> ___
>> es-discuss mailing list
>> es-discuss@mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
> 
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Label statement moveable

2015-05-20 Thread Emanuel Allen
Just wanted to see what type of effect if we modify their behavior to where the 
continue statement is allow in ant type of block statement as continue to this 
name label statement, starting from the top of the label block scope. Combine 
this with the power to break from that block statement with the key word 
break(like it can now), but also modified to where if a name label does not 
follow it'll break back to the continue that(in a sense) goto to the statement 
we are breaking from and continue onward with the code... 

In short, yes. I want to be able to continue/break from one block statement to 
another 

JS4Lf

> On May 20, 2015, at 6:45 AM, Sebastian McKenzie  wrote:
> 
> So you want to add goto to JavaScript?
> 
> 
> 
> 
>> On Wed, May 20, 2015 at 11:42 AM, Emanuel Allen  
>> wrote:
>> Clarify:
>> 
>> My previous post was not that clear. That post display what I would like to 
>> do in the language. Here is the actual code if I choose to do it as the 
>> language is now: 
>> var i = 0, n = 5;
>> l2: do {
>>  i += 1;
>>  l3: do {
>>if (i>else break l3;
>>  } while (true);
>>  break l2;
>> } while (true);
>> //just log the value n+1:
>> console.log('i:'+i);
>> 
>> loop through label l2 n amount of times before breaking.
>> 
>> This could be useful to escape function invocation cost, if it could be 
>> simply express:
>>  l2: {
>>   i += 1;
>>  }
>>  l3: {
>>if (i>  }
>> 
>> The function way is to:
>> function l2(){
>>   i += 1;
>> }
>> 
>> l3: do {
>>if (i>else break l3;
>>  } while (true);
>> 
>> I did a http://jsperf.com/block-scope-vs-function-invocation";>
>> jsprf to further my argument for a sudo goto/function effect:
>> 
>> http://jsperf.com/block-scope-vs-function-invocation
>> 
>> JS4Lf
>> 
>>> On May 19, 2015, at 2:45 PM, L4L  wrote:
>>> 
>>> Since we have block scope, and we have continue statement to which we can 
>>> use in loops to jump back to the conduction statement part. 
>>> 
>>> Than can we consider making label stamens moveable by its name. 
>>> 
>>> I'll like to say that the side effect would be sudo(pseudo) function, 
>>> example:
>>> 
>>> function foo(v){
>>>  return v + 1;
>>> }
>>> 
>>> 
>>>  var i = 0;
>>> 
>>>  baz:{
>>>i += 1;
>>>  }
>>> 
>>> continue baz;//same as foo(i);
>>> 
>>> console.log(i);
>>> 
>>> Note that I said sudo function. Its mobility is what of value; depending on 
>>> how JavaScript handle the continue statement in a loop to transport that 
>>> effect out side a loop. 
>>> 
>>> Stripping this privilege to black scope; where the continue statement is 
>>> expanded to work only in block scope and nested block scope; to where it 
>>> can only jump to the beginning of that block or any other block scope that 
>>> is scoped to that outer block scope but not nested block scope with in the 
>>> scope... Like function.
>>> 
>>> Continue and break statement could be of more power; where we can avoid 
>>> some function call in "speed matter" application.
>>> 
>>> Excuse any grammar errors. 
>>> 
>>> JS4Lf
>>> ___
>>> es-discuss mailing list
>>> es-discuss@mozilla.org
>>> https://mail.mozilla.org/listinfo/es-discuss
> 
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Label statement moveable

2015-05-20 Thread Emanuel Allen
Clarify:

My previous post was not that clear. That post display what I would like to do 
in the language. Here is the actual code if I choose to do it as the language 
is now: 
var i = 0, n = 5;
l2: do {
 i += 1;
 l3: do {
   if (ihttp://jsperf.com/block-scope-vs-function-invocation";>
jsprf to further my argument for a sudo goto/function effect:

http://jsperf.com/block-scope-vs-function-invocation

JS4Lf

> On May 19, 2015, at 2:45 PM, L4L  wrote:
> 
> Since we have block scope, and we have continue statement to which we can use 
> in loops to jump back to the conduction statement part. 
> 
> Than can we consider making label stamens moveable by its name. 
> 
> I'll like to say that the side effect would be sudo(pseudo) function, example:
> 
> function foo(v){
>  return v + 1;
> }
> 
> 
>  var i = 0;
> 
>  baz:{
>i += 1;
>  }
> 
> continue baz;//same as foo(i);
> 
> console.log(i);
> 
> Note that I said sudo function. Its mobility is what of value; depending on 
> how JavaScript handle the continue statement in a loop to transport that 
> effect out side a loop. 
> 
> Stripping this privilege to black scope; where the continue statement is 
> expanded to work only in block scope and nested block scope; to where it can 
> only jump to the beginning of that block or any other block scope that is 
> scoped to that outer block scope but not nested block scope with in the 
> scope... Like function.
> 
> Continue and break statement could be of more power; where we can avoid some 
> function call in "speed matter" application.
> 
> Excuse any grammar errors. 
> 
> JS4Lf
> ___
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Consider javascript already support for default parameters, so maybe we can use the default parameter to specify the strong type.

2015-05-18 Thread Emanuel Allen
I like to use what the language already have so if we can denote the type by 
constructor:

Function foo(a=Number(64),b=String()){
 return b+a;
}

Sent from my iPhone

> On May 18, 2015, at 2:23 PM, Edwin Reynoso  wrote:
> 
> Don't you just mean:
> 
> ```
> function addWithType(a=0, b=0) {
>   return int64(a) + int64(b);
> }
> ```
> 
>> On Mon, May 18, 2015 at 2:16 PM, Benjamin Gruenaum  
>> wrote:
>> What about non-default parameters?
>> 
>> ___
>> es-discuss mailing list
>> es-discuss@mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
> 
> ___
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Can't do push in forEach

2015-05-15 Thread Emanuel Allen
You mean by a library I favorite native support over importing a library.:. 
Although that will change ones import and export are supported. The pain of 
knowing that it was in Firefox and Netscape at one point in time.

Sent from my iPhone

> On May 15, 2015, at 5:46 AM, Dmitry Soshnikov  
> wrote:
> 
> In ES2015 (available today via transpilers), one can do:
> 
> arr1.push(...arr2);
> 
> Dmitry
> 
>> On Thursday, May 14, 2015, Emanuel Allen  wrote:
>> kudos to you sir or ma'am, It work!
>> 
>> var arr = [9,8,7,'a','b','c'], arr2 = [];
>> 
>> [].push.apply(arr2,arr);
>> 
>> arr2;// [9,8,7,'a','b','c']
>> 
>> JS4L
>> 
>>> On May 14, 2015, at 6:40 PM, Michael Haufe  wrote:
>>> 
>>> ...but you can do this:
>>> 
>>> [].push.apply(arr1,arr2);
>>> 
>>>> On Thu, May 14, 2015 at 9:25 AM, Emanuel Allen  
>>>> wrote:
>>>> Surprise that I can't do arr1.forEeach(arr2.push);
>>>> 
>>>> Will throw an error.
>>>> 
>>>> Using bind as:
>>>> 
>>>> push = arr2.bind(push);
>>>> arr1.forEeach(push);
>>>> 
>>>> Works... And not work. Seem to push individual elements and after every 
>>>> second element, it'll push the hold array.. And after and before each 
>>>> index that hold the array there are duplicate of that element preceding 
>>>> and following:
>>>> 
>>>> [1,2,array,2,3]//not this is with shift method
>>>> [1,2,array,3,2]//note that this is with push
>>>> 
>>>> 
>>>> JS4L
>>>> ___
>>>> es-discuss mailing list
>>>> es-discuss@mozilla.org
>>>> https://mail.mozilla.org/listinfo/es-discuss
>>> 
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Can't do push in forEach

2015-05-14 Thread Emanuel Allen
kudos to you sir or ma'am, It work!

var arr = [9,8,7,'a','b','c'], arr2 = [];

[].push.apply(arr2,arr);

arr2;// [9,8,7,'a','b','c']

JS4L

> On May 14, 2015, at 6:40 PM, Michael Haufe  wrote:
> 
> ...but you can do this:
> 
> [].push.apply(arr1,arr2);
> 
>> On Thu, May 14, 2015 at 9:25 AM, Emanuel Allen  
>> wrote:
>> Surprise that I can't do arr1.forEeach(arr2.push);
>> 
>> Will throw an error.
>> 
>> Using bind as:
>> 
>> push = arr2.bind(push);
>> arr1.forEeach(push);
>> 
>> Works... And not work. Seem to push individual elements and after every 
>> second element, it'll push the hold array.. And after and before each index 
>> that hold the array there are duplicate of that element preceding and 
>> following:
>> 
>> [1,2,array,2,3]//not this is with shift method
>> [1,2,array,3,2]//note that this is with push
>> 
>> 
>> JS4L
>> ___
>> es-discuss mailing list
>> es-discuss@mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
> 
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Can't do push in forEach

2015-05-14 Thread Emanuel Allen
Yes I was thinking that too. But if it just default to binding to the object on 
which the method is being call on it self since this is technically an partial 
application function.

Or it can have a forth optional parameters to allow what object should be this. 
Or can simple just use bind call or apply method.

Sent from my iPhone

> On May 14, 2015, at 3:07 PM, Jordan Harband  wrote:
> 
> `arr.push` is `Array.prototype.push`. If you want it bound to `arr`, you'd 
> need to use `.bind` or actually call it with `arr.push()`. `arr.push.only` 
> would lose the context of the "arr", so that's not an option for your use 
> case as described.
> 
> Arrow functions (with Array#map perhaps?) are your best bet here.
> 
>> On Thu, May 14, 2015 at 11:50 AM, Andrea Giammarchi 
>>  wrote:
>> > So this style I favorite since I want to avoid creating another function:
>> 
>> this is like believing that `fn.bind()` won't create a different 
>> object/function ... right?
>> 
>> Or you want to lock that function to receive one forever until you unlock 
>> it? That's the only way you could mutate the function behavior without 
>> creating a new object/function like bind would do.
>> 
>> And since bind is at least 3X slower than fat arrow, why would you do that?
>> 
>> 
>>> On Thu, May 14, 2015 at 7:36 PM, Emanuel Allen  
>>> wrote:
>>> It should allow for:
>>> 
>>> arr.forEach(arr.push.only(1));//only return a function limiting the number 
>>> of arguments pass to it...
>>> 
>>> But I guess this work too:
>>> arr.forEach(e=>arr.push(e));
>>> 
>>> But my goal was to just:
>>> arr.forEach(arr.push);//will not work
>>> 
>>> So this style I favorite since I want to avoid creating another function:
>>> arr.forEach(arr.push.only(1));
>>> 
>>> Even know only will return another function base on the parameter to you 
>>> pass to it.
>>> 
>>> Still, I think it would be a great addition to the Function.prototype 
>>> object.
>>> 
>>> JS4L
>>> 
>>>> On May 14, 2015, at 1:42 PM, Andrea Giammarchi 
>>>>  wrote:
>>>> 
>>>> `$1 => a.push($1)`
>>>> 
>>>> fat arrow function shines mostly in these cases, not sure there's a need 
>>>> for anything else.
>>>> 
>>>> `($1, $2, $3) => a.push($2, $3)`
>>>> 
>>>> Regards
>>>> 
>>>>> On Thu, May 14, 2015 at 5:26 PM, Emanuel Allen  
>>>>> wrote:
>>>>> That would be great to have an only method on Function.prototype.only
>>>>> 
>>>>> It can take one to three parameters as arguments:
>>>>> -Only with using the first argument:
>>>>> 
>>>>> SomeFunction.only(1);
>>>>> only allow the first argument in. It target the place holder so: 
>>>>> fn.only(2) allow the two most left argument in.
>>>>> 
>>>>> -Only with using the first 2 argument:
>>>>> 
>>>>> SomeFunction.only(1,2);
>>>>> only allow the second argument in; the second argument target where to 
>>>>> start and the first not how many to let in. So fn.only(2,3); let the 
>>>>> third and fourth argument in. 
>>>>> 
>>>>> -Only with using all arguments placeholder:
>>>>> 
>>>>> SomeFunction.only(1,2,true);
>>>>> This will denote that we start from the right and and let the second from 
>>>>> last argument in 
>>>>> 
>>>>> The last parameter is informing if we should start left or right when 
>>>>> choosing the parameters to let in. The default is false; start left to 
>>>>> right 
>>>>> 
>>>>> Internally this could use the function's arguments object to query what 
>>>>> to let in.
>>>>> 
>>>>> JS4L
>>>>> 
>>>>>> On May 14, 2015, at 11:37 AM, Allen Wirfs-Brock  
>>>>>> wrote:
>>>>>> 
>>>>>> 
>>>>>>> On May 14, 2015, at 8:19 AM, Emanuel Allen wrote:
>>>>>>> 
>>>>>>> Oh yes that is correct since push will push in elements separated by 
>>>>>>> commas... Still my original problem is that I can't simply do 
>>>>>>> arr.push(arr2.push); but it doesn't matter since it'

Re: Can't do push in forEach

2015-05-14 Thread Emanuel Allen
> > So this style I favorite since I want to avoid creating another function:
> 
> this is like believing that `fn.bind()` won't create a different 
> object/function ... right?

I like how you pick out my word (like a certain gender group would) even know I 
re correct my self right after that with: 
>> Even know only will return another function base on the parameter to you 
>> pass to it.
Sent from my iPhone

> On May 14, 2015, at 2:50 PM, Andrea Giammarchi  
> wrote:
> 
> > So this style I favorite since I want to avoid creating another function:
> 
> this is like believing that `fn.bind()` won't create a different 
> object/function ... right?
> 
> Or you want to lock that function to receive one forever until you unlock it? 
> That's the only way you could mutate the function behavior without creating a 
> new object/function like bind would do.
> 
> And since bind is at least 3X slower than fat arrow, why would you do that?
> 
> 
>> On Thu, May 14, 2015 at 7:36 PM, Emanuel Allen  
>> wrote:
>> It should allow for:
>> 
>> arr.forEach(arr.push.only(1));//only return a function limiting the number 
>> of arguments pass to it...
>> 
>> But I guess this work too:
>> arr.forEach(e=>arr.push(e));
>> 
>> But my goal was to just:
>> arr.forEach(arr.push);//will not work
>> 
>> So this style I favorite since I want to avoid creating another function:
>> arr.forEach(arr.push.only(1));
>> 
>> Even know only will return another function base on the parameter to you 
>> pass to it.
>> 
>> Still, I think it would be a great addition to the Function.prototype object.
>> 
>> JS4L
>> 
>>> On May 14, 2015, at 1:42 PM, Andrea Giammarchi 
>>>  wrote:
>>> 
>>> `$1 => a.push($1)`
>>> 
>>> fat arrow function shines mostly in these cases, not sure there's a need 
>>> for anything else.
>>> 
>>> `($1, $2, $3) => a.push($2, $3)`
>>> 
>>> Regards
>>> 
>>>> On Thu, May 14, 2015 at 5:26 PM, Emanuel Allen  
>>>> wrote:
>>>> That would be great to have an only method on Function.prototype.only
>>>> 
>>>> It can take one to three parameters as arguments:
>>>> -Only with using the first argument:
>>>> 
>>>> SomeFunction.only(1);
>>>> only allow the first argument in. It target the place holder so: 
>>>> fn.only(2) allow the two most left argument in.
>>>> 
>>>> -Only with using the first 2 argument:
>>>> 
>>>> SomeFunction.only(1,2);
>>>> only allow the second argument in; the second argument target where to 
>>>> start and the first not how many to let in. So fn.only(2,3); let the third 
>>>> and fourth argument in. 
>>>> 
>>>> -Only with using all arguments placeholder:
>>>> 
>>>> SomeFunction.only(1,2,true);
>>>> This will denote that we start from the right and and let the second from 
>>>> last argument in 
>>>> 
>>>> The last parameter is informing if we should start left or right when 
>>>> choosing the parameters to let in. The default is false; start left to 
>>>> right 
>>>> 
>>>> Internally this could use the function's arguments object to query what to 
>>>> let in.
>>>> 
>>>> JS4L
>>>> 
>>>>> On May 14, 2015, at 11:37 AM, Allen Wirfs-Brock  
>>>>> wrote:
>>>>> 
>>>>> 
>>>>>> On May 14, 2015, at 8:19 AM, Emanuel Allen wrote:
>>>>>> 
>>>>>> Oh yes that is correct since push will push in elements separated by 
>>>>>> commas... Still my original problem is that I can't simply do 
>>>>>> arr.push(arr2.push); but it doesn't matter since it'll also push the 
>>>>>> three parameters into the array as well. 
>>>>> 
>>>>> exactly, see http://www.wirfs-brock.com/allen/posts/166 
>>>>> 
>>>>>> 
>>>>>> 
>>>>>> Sent from my iPhone
>>>>>> 
>>>>>>> On May 14, 2015, at 10:49 AM, Erik Arvidsson  
>>>>>>> wrote:
>>>>>>> 
>>>>>>> Still, the callback for forEach is called with 3 arguments; value, 
>>>>>>> index and the array.
>>>>>>> 
>>>>>>> This is clearly docu

Re: Can't do push in forEach

2015-05-14 Thread Emanuel Allen
It should allow for:

arr.forEach(arr.push.only(1));//only return a function limiting the number of 
arguments pass to it...

But I guess this work too:
arr.forEach(e=>arr.push(e));

But my goal was to just:
arr.forEach(arr.push);//will not work

So this style I favorite since I want to avoid creating another function:
arr.forEach(arr.push.only(1));

Even know only will return another function base on the parameter to you pass 
to it.

Still, I think it would be a great addition to the Function.prototype object.

JS4L

> On May 14, 2015, at 1:42 PM, Andrea Giammarchi  
> wrote:
> 
> `$1 => a.push($1)`
> 
> fat arrow function shines mostly in these cases, not sure there's a need for 
> anything else.
> 
> `($1, $2, $3) => a.push($2, $3)`
> 
> Regards
> 
>> On Thu, May 14, 2015 at 5:26 PM, Emanuel Allen  
>> wrote:
>> That would be great to have an only method on Function.prototype.only
>> 
>> It can take one to three parameters as arguments:
>> -Only with using the first argument:
>> 
>> SomeFunction.only(1);
>> only allow the first argument in. It target the place holder so: fn.only(2) 
>> allow the two most left argument in.
>> 
>> -Only with using the first 2 argument:
>> 
>> SomeFunction.only(1,2);
>> only allow the second argument in; the second argument target where to start 
>> and the first not how many to let in. So fn.only(2,3); let the third and 
>> fourth argument in. 
>> 
>> -Only with using all arguments placeholder:
>> 
>> SomeFunction.only(1,2,true);
>> This will denote that we start from the right and and let the second from 
>> last argument in 
>> 
>> The last parameter is informing if we should start left or right when 
>> choosing the parameters to let in. The default is false; start left to right 
>> 
>> Internally this could use the function's arguments object to query what to 
>> let in.
>> 
>> JS4L
>> 
>>> On May 14, 2015, at 11:37 AM, Allen Wirfs-Brock  
>>> wrote:
>>> 
>>> 
>>>> On May 14, 2015, at 8:19 AM, Emanuel Allen wrote:
>>>> 
>>>> Oh yes that is correct since push will push in elements separated by 
>>>> commas... Still my original problem is that I can't simply do 
>>>> arr.push(arr2.push); but it doesn't matter since it'll also push the three 
>>>> parameters into the array as well. 
>>> 
>>> exactly, see http://www.wirfs-brock.com/allen/posts/166 
>>> 
>>>> 
>>>> 
>>>> Sent from my iPhone
>>>> 
>>>>> On May 14, 2015, at 10:49 AM, Erik Arvidsson  
>>>>> wrote:
>>>>> 
>>>>> Still, the callback for forEach is called with 3 arguments; value, index 
>>>>> and the array.
>>>>> 
>>>>> This is clearly documented in the spec and mdn and other resources.
>>>>> 
>>>>> 
>>>>>> On Thu, May 14, 2015, 10:42 Garrett Smith  wrote:
>>>>>> On 5/14/15, Emanuel Allen  wrote:
>>>>>> > Surprise that I can't do arr1.forEeach(arr2.push);
>>>>>> >
>>>>>> 
>>>>>> Check that line more carefully.
>>>>>> 
>>>>>> 
>>>>>> > Will throw an error.
>>>>>> >
>>>>>> > Using bind as:
>>>>>> >
>>>>>> > push = arr2.bind(push);
>>>>>> 
>>>>>> Arrays don't have a bind method.
>>>>>> --
>>>>>> Garrett
>>>>>> @xkit
>>>>>> ChordCycles.com
>>>>>> garretts.github.io
>>>>>> personx.tumblr.com
>>>>>> ___
>>>>>> es-discuss mailing list
>>>>>> es-discuss@mozilla.org
>>>>>> https://mail.mozilla.org/listinfo/es-discuss
>>>> ___
>>>> es-discuss mailing list
>>>> es-discuss@mozilla.org
>>>> https://mail.mozilla.org/listinfo/es-discuss
>> 
>> ___
>> es-discuss mailing list
>> es-discuss@mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
> 
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Can't do push in forEach

2015-05-14 Thread Emanuel Allen
That would be great to have an only method on Function.prototype.only

It can take one to three parameters as arguments:
-Only with using the first argument:

SomeFunction.only(1);
only allow the first argument in. It target the place holder so: fn.only(2) 
allow the two most left argument in.

-Only with using the first 2 argument:

SomeFunction.only(1,2);
only allow the second argument in; the second argument target where to start 
and the first not how many to let in. So fn.only(2,3); let the third and fourth 
argument in. 

-Only with using all arguments placeholder:

SomeFunction.only(1,2,true);
This will denote that we start from the right and and let the second from last 
argument in 

The last parameter is informing if we should start left or right when choosing 
the parameters to let in. The default is false; start left to right 

Internally this could use the function's arguments object to query what to let 
in.

JS4L

> On May 14, 2015, at 11:37 AM, Allen Wirfs-Brock  wrote:
> 
> 
>> On May 14, 2015, at 8:19 AM, Emanuel Allen wrote:
>> 
>> Oh yes that is correct since push will push in elements separated by 
>> commas... Still my original problem is that I can't simply do 
>> arr.push(arr2.push); but it doesn't matter since it'll also push the three 
>> parameters into the array as well. 
> 
> exactly, see http://www.wirfs-brock.com/allen/posts/166 
> 
>> 
>> 
>> Sent from my iPhone
>> 
>>> On May 14, 2015, at 10:49 AM, Erik Arvidsson  
>>> wrote:
>>> 
>>> Still, the callback for forEach is called with 3 arguments; value, index 
>>> and the array.
>>> 
>>> This is clearly documented in the spec and mdn and other resources.
>>> 
>>> 
>>>> On Thu, May 14, 2015, 10:42 Garrett Smith  wrote:
>>>> On 5/14/15, Emanuel Allen  wrote:
>>>> > Surprise that I can't do arr1.forEeach(arr2.push);
>>>> >
>>>> 
>>>> Check that line more carefully.
>>>> 
>>>> 
>>>> > Will throw an error.
>>>> >
>>>> > Using bind as:
>>>> >
>>>> > push = arr2.bind(push);
>>>> 
>>>> Arrays don't have a bind method.
>>>> --
>>>> Garrett
>>>> @xkit
>>>> ChordCycles.com
>>>> garretts.github.io
>>>> personx.tumblr.com
>>>> ___
>>>> es-discuss mailing list
>>>> es-discuss@mozilla.org
>>>> https://mail.mozilla.org/listinfo/es-discuss
>> ___
>> es-discuss mailing list
>> es-discuss@mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
> 
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Can't do push in forEach

2015-05-14 Thread Emanuel Allen
Oh yes that is correct since push will push in elements separated by commas... 
Still my original problem is that I can't simply do arr.push(arr2.push); but it 
doesn't matter since it'll also push the three parameters into the array as 
well. 


Sent from my iPhone

> On May 14, 2015, at 10:49 AM, Erik Arvidsson  wrote:
> 
> Still, the callback for forEach is called with 3 arguments; value, index and 
> the array.
> 
> This is clearly documented in the spec and mdn and other resources.
> 
> 
>> On Thu, May 14, 2015, 10:42 Garrett Smith  wrote:
>> On 5/14/15, Emanuel Allen  wrote:
>> > Surprise that I can't do arr1.forEeach(arr2.push);
>> >
>> 
>> Check that line more carefully.
>> 
>> 
>> > Will throw an error.
>> >
>> > Using bind as:
>> >
>> > push = arr2.bind(push);
>> 
>> Arrays don't have a bind method.
>> --
>> Garrett
>> @xkit
>> ChordCycles.com
>> garretts.github.io
>> personx.tumblr.com
>> ___
>> es-discuss mailing list
>> es-discuss@mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Can't do push in forEach

2015-05-14 Thread Emanuel Allen
Meant the method of the array not the array m itself: 
array["push"&&"unshift"].bind(array);

Sent from my iPhone

> On May 14, 2015, at 10:42 AM, Garrett Smith  wrote:
> 
>> On 5/14/15, Emanuel Allen  wrote:
>> Surprise that I can't do arr1.forEeach(arr2.push);
> 
> Check that line more carefully.
> 
> 
>> Will throw an error.
>> 
>> Using bind as:
>> 
>> push = arr2.bind(push);
> 
> Arrays don't have a bind method.
> -- 
> Garrett
> @xkit
> ChordCycles.com
> garretts.github.io
> personx.tumblr.com
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Can't do push in forEach

2015-05-14 Thread Emanuel Allen
Surprise that I can't do arr1.forEeach(arr2.push);

Will throw an error.

Using bind as:

push = arr2.bind(push); 
arr1.forEeach(push);

Works... And not work. Seem to push individual elements and after every second 
element, it'll push the hold array.. And after and before each index that hold 
the array there are duplicate of that element preceding and following:

[1,2,array,2,3]//not this is with shift method
[1,2,array,3,2]//note that this is with push


JS4L
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Evaluate postfix after assignment

2015-05-12 Thread Emanuel Allen
Oh wow that seem like a lot of work the interpreter is doing...

Thank you for the explanation guys/gals.

Aim to be a JS MASTER.

> On May 12, 2015, at 6:25 PM, Bergi  wrote:
> 
> Emanuel Allen schrieb:
>> Typo. I'm worrying about this:
>> 
>> arr[i++]=obj[e]
>> 
>> arr[i++]//this will evaluate first before the value return since the = have 
>> a lower
>> precedence than ++.
> 
> Notice that operator precedence has to do with parsing an (otherwise 
> ambiguous) expression, not with evaulation order.
> 
> So this is parsed to
> 
>  (((arr)[((i)++)])=((obj)[(e)]))
> 
> and then basically evaluated left-to-right.
> 
> Bergi
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Evaluate postfix after assignment

2015-05-12 Thread Emanuel Allen
Typo. I'm worrying about this:

arr[i++]=obj[e]

More so the return =obj[e]

I worry on this:

arr[i++]//this will evaluate first before the value return since the = have a 
lower  
precedence than ++.

So the index that is assign the object will be the index that contains it's 
string name.

Here reference for precedence:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence

> On May 12, 2015, at 3:08 PM, Rick Waldron  wrote:
> 
> 
> 
>> On Tue, May 12, 2015 at 1:58 PM Emanuel Allen  
>> wrote:
>> Is this the same across browsers:
>> var i = 0, arr = 'a','b','c'], e,
>> obj = {a:{name:'a'}, b:{name:'b'},c:{name:'c'}};
>> while ((e=arr[i])&&(arr[i++]=obj[e]));
>> 
>> //output:
>> >arr
>> >[{name:'a'},{name:'b'},{name:'c'}]
> 
> Yes
>  
>> 
>> I'm worrying about the "i++"...
> 
> Worried about what, exactly?
> 
> Your subject says "prefix", but this is the postfix operator.
>  
>> I test it out in node's repl... V8... Should the language it self be the 
>> same across browsers in situation like this?
> 
> Yes, absolutely. It's explicitly described in the spec (and has been for a 
> very long time).  
> 
> Rick
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Evaluate prefix after assignment

2015-05-12 Thread Emanuel Allen
Is this the same across browsers:
var i = 0, arr = 'a','b','c'], e, 
obj = {a:{name:'a'}, b:{name:'b'},c:{name:'c'}};
while ((e=arr[i])&&(arr[i++]=obj[e]));

//output:
>arr
>[{name:'a'},{name:'b'},{name:'c'}]

I'm worrying about the "i++"... I test it out in node's repl... V8... Should 
the language it self be the same across browsers in situation like this?
Sent from my iPhone
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss