Re: Array.forEach() et al with additional parameters

2014-12-22 Thread David Bruant
Le 20/12/2014 13:47, Gary Guo a écrit : bindParameter function is not very hard to implement: ``` Function.prototype.bindParameter=function(idx, val){ var func=this; return function(){ var arg=Array.prototype.slice.call(arguments); arg[idx]=val; func.apply(this,

RE: Array.forEach() et al with additional parameters

2014-12-22 Thread Gary Guo
On Mon, 22 Dec 2014 11:37:04 +0100, David Bruant bruan...@gmail.com wrote:Function.prototype.bindParameter = function(...args){ return this.bind(undefined, ...args) } But this will bind all parameters. In Christian Mayer's situation, she wants first three parameters unbound while your

RE: Will `for (var a of null) {}` throw an error?

2014-12-22 Thread Gary Guo
On Mon, 22 Dec 2014 21:06:18 +0800, Glen Huang curvedm...@gmail.com wrote:Ideally it shouldn’t, because its twin `for (var a in null) {}` won’t. But looking at step 8 in

Re: Array.forEach() et al with additional parameters

2014-12-22 Thread Andrea Giammarchi
if you don't need a context, you can simply use it to pass anything you want. as example, instead of this On Sat, Dec 20, 2014 at 12:12 PM, Christian Mayer m...@christianmayer.de wrote: [1,2,3].forEach( myCallback, undefined, 'additionalFoo' ); you could do this: [1,2,3].forEach( callback,

Re: Array.forEach() et al with additional parameters

2014-12-22 Thread Andrea Giammarchi
forgot squared brckets ... myCallback.apply(nulll, [element, count, array].concat(this)); On Mon, Dec 22, 2014 at 1:29 PM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: if you don't need a context, you can simply use it to pass anything you want. as example, instead of this On

Re: Will `for (var a of null) {}` throw an error?

2014-12-22 Thread Glen Huang
In that case we have a gotcha. Is there any interest to change that behavior? Since es6 isn’t finial yet. On Dec 22, 2014, at 9:29 PM, Gary Guo nbdd0...@hotmail.com wrote: On Mon, 22 Dec 2014 21:06:18 +0800, Glen Huang curvedm...@gmail.com wrote: Ideally it shouldn’t, because its twin `for

Re: Will `for (var a of null) {}` throw an error?

2014-12-22 Thread Domenic Denicola
for in and for of do completely different things and there is no reason to expect consistency between them. This was discussed already; search esdiscuss.org. On Dec 22, 2014 8:37 AM, Glen Huang curvedm...@gmail.com wrote: In that case we have a gotcha. Is there any interest to change that

Re: Array.forEach() et al with additional parameters

2014-12-22 Thread Marius Gundersen
doesn't fat-arrow solve this? It's not that verbose, and you can put the arguments in any order you want ```js [1,2,3].forEach(element = myCallback(something else, element)); ``` Marius Gundersen ___ es-discuss mailing list es-discuss@mozilla.org

Re: Will `for (var a of null) {}` throw an error?

2014-12-22 Thread Glen Huang
Thanks. Found that discussion, and after thinking about it again, throwing errors on null/undefined actually makes sense, because it’s impossible to sliently loop over null/undefined with regular for loop (if you check length directly) or forEach directly. So throwing an error is actually

Re: Any news about the `module` element?

2014-12-22 Thread Isiah Meadows
From: Allen Wirfs-Brock al...@wirfs-brock.com To: Anne van Kesteren ann...@annevk.nl Cc: es-discuss list es-discuss@mozilla.org Date: Sun, 21 Dec 2014 14:45:08 -0800 Subject: Re: Any news about the `module` element? On Dec 21, 2014, at 10:10 AM, Anne van Kesteren wrote: On Sun, Dec 21,

RE: Will `for (var a of null) {}` throw an error?

2014-12-22 Thread Gary Guo
Actually I propose a change in texts in the specification. CheckIterable ( obj )1. If obj is `undefined` or `null`, then return `undefined`.2. If type(obj) is Object, then return Get(obj, @@iterator).3. Let box be ToObject(obj).4. ReturnIfAbrupt(box).5. Return the result of calling the

Re: Will `for (var a of null) {}` throw an error?

2014-12-22 Thread Brendan Eich
Your suggestion breaks Array.from and TypedArrayFrom. /be Gary Guo wrote: I suggest we can a little bit combine these steps: CheckIterable (obj) 1. Let box be ToObject(obj). 2. ReturnIfAbrupt(box). 3. Return the result of calling the [[Get]] internal method of box passing @@iterator and

Elegant way to generate string from tagged template?

2014-12-22 Thread Glen Huang
When a template is passed to a function, what’s the quickest way to return a string with additional arguments being interpolated into the template? For example, ``` minify` ul li${content}/li /ul ` ``` In this case`minify` will return the minified html, but

RE: Will `for (var a of null) {}` throw an error?

2014-12-22 Thread Gary Guo
Date: Mon, 22 Dec 2014 21:28:54 -0800 From: bren...@mozilla.org Your suggestion breaks Array.from and TypedArrayFrom. In the spec: 8. Let arrayLike be ToObject(items). A type error will also be thrown since null and undefined are not ObjectCoercible.