Lets say I have this function, I am trying to get values of value1 and 2 , what’s the right way to do it. 1. how do I make value 1 and value 2 defined , when it exits the function 2. how do i get the value in another function without calling “doSomething” function
test.prototype.doSomething = function (){
test = new Execution(experiment);
function experiment(bla) {
forEach(function(bla) {
var value1 = bla.value1;
var value2 = bla.balue2;
console.log(value1); //defined
});
console.log(value1); //undefined
}
console.log(value1); //undefined
}
test.prototype.testSomething = function() {
var testSomething = values1;
}
You can try by declaring value1 and value2 out of experiment function and assign value to those variable within the function. Below is code:
}