The short answer is NO.
The longer one is no, because JavaScript works with scopes. If you define the same variable again, it overrides the parent one. There are a few tricks to get it, but they all include reference to the parent object. Here are a few examples:
var start = 'start';
console.log(start); // 'start'
function test(start) {
console.log(start); // 'test' - you got no reference to previous start
}
test('test');
Using globally (window):
start = 'start'; // global, without var, at document/window level
function test(start) {
console.log(start); // test
console.log(this.start); // start, because THIS is window/document
}
test('test');
BUT keep in mind, that this can be changed. Therefore there's no real proof that you will be able to get it.
Sometimes you will be able to do this:
function main() {
this.start = 'start';
return function(start) {
console.log(start); // 'test'
console.log(this.start); // 'start'
}
}
var class = main();
class.test('test');
It all depends on your structure and if you wrap your things inside functions. Best practice is to just use different names. In some languages it's common to prefix your variables with _
, like _start
, which means that they are member
variables (most top level as possible). Some people even suffix the parameter's variables (start_
) so they know what's going on. I'm not fan of that, but still.