【发布时间】:2018-04-08 16:27:19
【问题描述】:
在一种方法中创建的值可以通过调用在另一种方法中使用,但在我的情况下我得到一个错误。请指教
(function() {
var s = {
appendToFilter: function(bread, value) {
console.log(bread); // value is 20
console.log(value); // value is 40
return value; // Need this value
},
//Append to container in order to render filters
appendToContainer: function(container, v, state) {
// I need the value returned in appendToFilter here
// I tried using global variable and tried to call appendToFilter here, no luck
// since it depends on flow of the methods is there any work around to get the value
},
getToFilter: function(value) {
var x = 20;
var y = 40;
s.appendToFilter(x,y);
}
}
});
【问题讨论】:
标签: javascript object methods javascript-objects