Sometimes you have a function that receives a parameter shadowing an existing 
function or variable in the parent scope.

In _some_ cases I would like to use the same variable name to avoid having to 
come up with new names. Contrived example ahead:

```js
import path from "path"

function doSomething (_path) {
        if (path.dirname(_path) === "/" ) {
        // ...
        } else {
        }
}
```

It would be nice if there was a special construct like `typeof` or `instanceof` 
that would take a name and evaluate to whatever 
variable / function of the same name existing in the parent scope (or undefined 
otherwise).

```js
import path from "path"

function doSomething (path) {
        if ((insteadof path).dirname(path) === "/" ) {
        // ...
        } else {
        }
}
```

In this case the expression above using the made-up `inteadof` operator would 
evaluate to the imported `path` variable
instead of the `path` variable name.


Regards
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to