Re: Proposal: ignored arguments

2016-03-04 Thread Alan Johnson
What about something like a bare `.`? Putting nothing there seems a bit error prone, but using `_` non-ideal, as it clashes with the common practice of binding utility libraries to that name. For linters, it’s nice to be able to treat unused variables as an unconditional error. > On Mar 4,

Re: Provide hooks for Content Security Policy (CSP)?

2016-03-04 Thread Andrea Giammarchi
I'm not sure it's easy to understand what is this about, but if I read eval and Function as no-op under CSP I imagine the joy of Angular framework users since both version 1 and version 2 have various bits based on evaluation ( example:

Object.prototype.forIn

2016-03-04 Thread Langdon
My apologies if this has been discussed before (I have to imagine it has, but couldn't find anything). Why isn't there a `forIn` method on Object natively? Something that simply wraps this all-to-common code: var key; for (key in obj) { if (obj.hasOwnProperty(key) === true) { ... } }

Re: Proposal: ignored arguments

2016-03-04 Thread /#!/JoePea
I don't see the benefit of allowing this in function definitions (why encourage bad design?), but I could see the benefit for function calls, where ```js function someFunk (foo, bar, baz) {...} someFunk( 1,,3 ) ``` would be the same as ```js function someFunk (foo, bar, baz) {...} someFunk( 1,

Re: Object.prototype.forIn

2016-03-04 Thread Langdon
Ahhh, nothing. I never think about destructuring. Thanks! On Fri, Mar 4, 2016 at 1:41 PM, Caitlin Potter wrote: > > Object.entries does look nice, but 2 arguments is more straightforward > than a passing around a pair. > > What’s the problem with `for (let [key, value]

Re: Object.prototype.forIn

2016-03-04 Thread Isiah Meadows
Yeah, and those effectively nullify this, anyways. On Fri, Mar 4, 2016, 12:55 Simon Blackwell wrote: > Not sure of the rationale; however, it looks like Chrome now supports > something similar natively: > > > > >

RE: Object.prototype.forIn

2016-03-04 Thread Simon Blackwell
No doubt … which brings us right back to the rationale question! From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of Langdon Sent: Friday, March 4, 2016 1:28 PM To: es-discuss@mozilla.org Subject: Re: Object.prototype.forIn My gripe with Object.keys is that it requires a

RE: Object.prototype.forIn

2016-03-04 Thread Simon Blackwell
Not sure of the rationale; however, it looks like Chrome now supports something similar natively: https://twitter.com/malyw/status/704972953029623808?utm_source=javascriptweekly_medium=email

Re: Object.prototype.forIn

2016-03-04 Thread Andrea Giammarchi
for (let key of Object.keys(obj)) { ... } On Fri, Mar 4, 2016 at 4:48 PM, Langdon wrote: > Ah, thanks. I had forgotten about Object.keys, but even that still > doesn't wrap things up as nicely as `forIn`. > > Object.entries looks nice. > > On Fri, Mar 4, 2016 at 11:37 AM,

Re: Object.prototype.forIn

2016-03-04 Thread Caitlin Potter
> Object.entries does look nice, but 2 arguments is more straightforward than a > passing around a pair. What’s the problem with `for (let [key, value] of Object.entries(obj)) { …. }` > As well (and perhaps more importantly), temporarily building an array of > arrays so we can forEach it,

RE: Provide hooks for Content Security Policy (CSP)?

2016-03-04 Thread Domenic Denicola
From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of Andrea Giammarchi > Can anyone explain with few words what does this change actual mean for JS ? It means that JS will now specify how it has been implemented already in every browser, in a more rigorous way that allows the

Re: Object.prototype.forIn

2016-03-04 Thread Edwin Reynoso
Okay that makes sense, but the `Object.forIn` confused me, then that'd be a bad name because then its not really looping like for-in On Fri, Mar 4, 2016 at 4:07 PM Logan Smyth wrote: > Edwin, the original example loop explicitly checks `obj.hasOwnProperty(key)`, > so

Re: Object.prototype.forIn

2016-03-04 Thread Logan Smyth
Edwin, the original example loop explicitly checks `obj.hasOwnProperty(key)`, so properties in the prototype chain are not an issue here. On Fri, Mar 4, 2016 at 1:04 PM, Edwin Reynoso wrote: > Sorry guys but this is very wrong, for in, loops through all properties > even the

Re: Object.prototype.forIn

2016-03-04 Thread Edwin Reynoso
Sorry guys but this is very wrong, for in, loops through all properties even the ones inherited from all prototypes, while Object.keys() and Object.entries() do not. They are indeed very different On Fri, Mar 4, 2016 at 1:45 PM Langdon wrote: > Ahhh, nothing. I never think

Re: Proposal: ignored arguments

2016-03-04 Thread Alan Johnson
A parameter in a function definition might be ignored if it’s meant to be called as a callback, but you it doesn’t care about some of the info passed in. > On Mar 4, 2016, at 11:28 AM, /#!/JoePea wrote: > > I don't see the benefit of allowing this in function definitions (why

Re: Re: Provide hooks for Content Security Policy (CSP)?

2016-03-04 Thread Ron Waldon
Are there CSP benefits for other JavaScript environments (e.g. Node.js)? Would there be benefits in applying CSP at the module level? e.g. module A has been vetted and can do these things, whilst module B is less trusted and has strict limitations ___

Re: Object.prototype.forIn

2016-03-04 Thread Jordan Harband
While I would like a function for this too, this is pretty trivial: ``` function* enumerate(obj) { for (var key in obj) { yield [key, obj[key]]; } } for (const [key, value] of enumerate(obj) { doStuff(key, value); } ``` On Fri, Mar 4, 2016 at 1:08 PM, Edwin Reynoso wrote:

Re: Re: Provide hooks for Content Security Policy (CSP)?

2016-03-04 Thread Isiah Meadows
Comments inline On Fri, Mar 4, 2016 at 11:08 PM, Domenic Denicola wrote: > From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of Ron > Waldon > >> Are there CSP benefits for other JavaScript environments (e.g. Node.js)? > > Yes; it is something that could in

RE: Re: Provide hooks for Content Security Policy (CSP)?

2016-03-04 Thread Domenic Denicola
From: es-discuss [mailto:es-discuss-boun...@mozilla.org] On Behalf Of Ron Waldon > Are there CSP benefits for other JavaScript environments (e.g. Node.js)? Yes; it is something that could in theory be exposed through Node's vm module (i.e. Realm creation API), which would help certain

Re: Object.prototype.forIn

2016-03-04 Thread Langdon
My gripe with Object.keys is that it requires a closure to use effectively. Object.entries does look nice, but 2 arguments is more straightforward than a passing around a pair. As well (and perhaps more importantly), temporarily building an array of arrays so we can forEach it, seems way less

Re: Object.prototype.forIn

2016-03-04 Thread Langdon
Ah, thanks. I had forgotten about Object.keys, but even that still doesn't wrap things up as nicely as `forIn`. Object.entries looks nice. On Fri, Mar 4, 2016 at 11:37 AM, Logan Smyth wrote: > You can already achieve this in ES5 with > > ``` >

Re: Object.prototype.forIn

2016-03-04 Thread Logan Smyth
You can already achieve this in ES5 with ``` Object.keys(obj).forEach(key => { }); ``` or in ES6 with ``` var key; for (key of Object.keys(obj)){ } ``` And with the new proposal, you'll also have `Object.values` for values and `Object.entries` for key/value pairs: