Im learning js , can u help me how to call variable js in object function
example
var obj = {
a : 'foo',
b : function(){
var ab = a + "bar"; <-- how to call var 'ab' outside var obj ..
alert(ab)
}
}
console.log(ab);
thanks
abas a variable inside the closure of functionb. What are you actually trying to do here? You could returnabfrom the functionbor you could make it a member your obj, or you can make it global.