1
votes

I have :

var config = {}

I have an function

$('.test').on("click",function() {
   config.test = 'new'
}, check())

and then a function, if object has new value and try to check if it has new value

function check() {
  if(config.test) {
    console.log('there is data')
  }
}

but that doesnt work, how would I do it?

maybe you can find some help here in details: stackoverflow.com/questions/1063813/…Diego De Vita
@Grumpy, what is the difference between config['test] and config.test?earlyBeard
@Grumpy how is going to change anything?? you just suggested a different way to access a property instead of dot operatorDiego De Vita
@earlyBeard you need to intercept when the property gets changed. So you need to bind a new setter that will first run your code saving the event and then will also store the value in the state of the object. Anyway since you were not perfectly clear about the extent of your interest I can't suggest something that doesn't scale general enough. The first link I shared is what you need but you'll have to understand those answers. It's still a SO question and it's the same as yours. But requires some work to fully understandDiego De Vita
What do you think , check() is doing? It is not being called onclick.epascarello