Forgot to mention that nameof works with local variables too:

function foo() {
 var aNum = 1;
 console.log(nameof(aNmum), aNum);
}


On Sat, Aug 8, 2015 at 10:38 AM Behrang Saeedzadeh <behran...@gmail.com>
wrote:

> So basically we could use it like this:
>
>
> function aFunc(aParam) {
>     throw new Error(nameof(aParam));
> }
>
>
> and nameof(aParam) would return the string "aParam".
>
>
> This is possible to do even right now using arguments.callee and some
> hacky code, but having it built-in to spec would be nicer IMHO.
> --
> Best regards,
> Behrang Saeedzadeh
>
-- 
Best regards,
Behrang Saeedzadeh
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to