Getting arguments passed to an ES6 arrow function using arguments variable
<p>I understand how arrow functions work in ES6, and the lexical this, but I was wondering if anyone knows of a way to get the arguments passed to an arrow function?</p>

<p>In ES5, you can simply do:</p>

<pre class="lang-js prettyprint-override"><code>function foo( bar, baz ){
    console.log('Args:', arguments.join(', '))
}
</code></pre>

<p>However, in ES6, if you use an arrow function, like so:</p>

<pre class="lang-js prettyprint-override"><code>const foo = ( bar, baz ) =&gt; {
    console.log('Args:', arguments.join(', '))
}
</code></pre>

<p>The <code>arguments</code> variable returns an object, which is nothing close to the parameters.</p>

<p>So, I was wondering if anyone has a way to get the arguments passed to an arrow function?</p>

<hr>

<h3>Edit</h3>

<p>I guess maybe I should give some info on what I'm trying to accomplish, maybe if the above isn't possible, someone has a better idea.</p>

<p>Basically, I'm adding a IIEF to the BluebirdJS <a href="http://bluebirdjs.com/docs/api/ascallback.html" rel="noreferrer">asCallback</a> method, which will determine if there was actually a callback provided, if not, it returns the promise.</p>

<p>Heres a working example in ES5:</p>

<pre class="lang-js prettyprint-override"><code>var _ = require('lodash')
var Promise = require('bluebird')

function testFunc( foo, callback ) {
    return new Promise( function ( res, rej ){
        res('You Said: ' + (_.isString( foo ) ? foo : 'NOTHING') )
    })
        .asCallback((function ( args ) {
            return _.findLast(args, function(a) {
                return _.isFunction( a )
            })
        })( arguments ))
}


testFunc('test', function( err, data ) {
    if( ! _.isEmpty( err ) )
        console.log('ERR:', err)
    else
        console.log('DATA: ', data)
})
// DATA:  You Said: test

testFunc(function( err, data ) {
    if( ! _.isEmpty( err ) )
        console.log('ERR:', err)
    else
        console.log('DATA: ', data)
})
// DATA:  You Said: NOTHING
</code></pre>

<p>So that works fine if I use all ES5 functions, and I don't mind using them for the IIEF, or inside it if needed. But this hinges on the <code>arguments</code> variable inside a function that I don't really want to use as an ES5 function, id rather stick to ES6 Arrow functions. So if theres some ES6 way to get arguments in an ES6 arrow function, that would be perfect!</p>