object - How to create a logical expression dynamically(@Runtime) in Javascript -


i have following objects passed function 'evaluateexpr': var d = { "brand" : "brand 1", "product" : "p1"} , var key = 'brand' //or 'product', var value = 'brand 1' //or 'p1'

i need create expression in function evaluated @ run time follows

var evaluateexpr= function(d,key,value){          var expr = d[key] === value;  //should evaluate d['brand'] === 'brand 1', if key = 'brand' , value = 'brand 1'        return expr;  

i have tried many things. d[key] returns value @ it's index position. example, gets evaluated so,

 'brand 1' === 'brand 1'  

rather should evaluated this,

d['brand'] === 'brand 1' 

how prevent javascript engine evaluating d[key] , leave is?


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -