How do you achieve the following thing in Javascript
1) var MyObject={
2) tableView:true,
3) chartView:!(this.tableView)
4) }
The code at line number 3 is not working. Whats wrong in that line ?
What i basically want to do is set “chartView” to opposite of “tableView” whenever tableView is set from code.
Since you’re in the process of creating the object,
thisis not bound to that object. Moreover, since you wantchartViewto always evaluate to the opposite oftableView, even if the latter changes further down the line, a function would be a better approach:Now you can do: