Hi
My question is NOT the topic covered in this thread:
https://bytes.com/topic/javascript/answers/809155-howto-get-variables-name-not-value-introspection
Here's my scenario:
What i'd like to happen is, in the Strike function, when b1 strikes b2, display the variable-name of the targetBilliard in the alert, "b2".
Something like:
NameOf(targetBi lliard)
i realize this may not be possible, but i'm guessing would require some sort of memory access?
thx!
My question is NOT the topic covered in this thread:
https://bytes.com/topic/javascript/answers/809155-howto-get-variables-name-not-value-introspection
Here's my scenario:
Code:
function Billiard(){
// position
this.position;
// strike another billiard
this.strike = function(targetBilliard, strength){
targetBilliard.position += strength;
alert(targetBilliard.number + ' position: ' + targetBilliard.position);
}
}
// make 2 billiards
var b1 = new Billiard;
b1.position = 8;
var b2 = new Billiard;
b2.position = 5;
// b1 strikes b2
b1.strike(b2, 5);
Something like:
NameOf(targetBi lliard)
i realize this may not be possible, but i'm guessing would require some sort of memory access?
thx!
Comment