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

Re: Label statement moveable

2015-05-20 Thread Emanuel Allen
? > > ``` > 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 go

Re: Label statement moveable

2015-05-20 Thread Emanuel Allen
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

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 fu

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) { > retu

Re: Can't do push in forEach

2015-05-15 Thread Emanuel Allen
kov > 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'

Re: Can't do push in forEach

2015-05-14 Thread Emanuel Allen
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);

Re: Can't do push in forEach

2015-05-14 Thread Emanuel Allen
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:

Re: Can't do push in forEach

2015-05-14 Thread Emanuel Allen
gt; 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));//on

Re: Can't do push in forEach

2015-05-14 Thread Emanuel Allen
> > `$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: >> T

Re: Can't do push in forEach

2015-05-14 Thread Emanuel Allen
x27;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 o

Re: Can't do push in forEach

2015-05-14 Thread Emanuel Allen
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 Smit

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.forEe

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 th

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] >

Re: Evaluate postfix after assignment

2015-05-12 Thread Emanuel Allen
ame. 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

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 languag