Q:

How to concatenate an object property to another string or variable in javascript

I want to concatenate an object property to a variable like this,
var foo = { bar_zen: 0, bar_jj: 0 }

var foo2 = $(this); // this comes from attr of an Id or class on click
if(foo.bar_+foo2+ == 0){ ..// do something }

A:

use bracket notation instead of dots:
if(foo["bar_" + foo2] == 0){ ..// do something }

