javascript - nodejs execute string variable -
I am using sails.js. 1) I want to print 'Dolphin' with the object matching call.
var matchCol = {'card': {'add': {'voo': 'dolphin'}}}; Module.exports = {methodA: function (Rick, Race) {var a = 'card'; Var B = 'Ed'; Var c = 'voo'; Return res.send (matchCol.a.b.c); },};
2) If I want to declare the object and want to parse the key 'foo', then how can I do it?
var key = 'foo'; Var params = {key: 'some'};
Please help. In Javascript, if you have a variable that represents the property name of an object, you can access it by entering the < To use square brackets you can:
return res.send (matchcol [a] [b] [c]);
You can also use square brackets for assignments:
var key = 'foo'; Var Params = {}; Consultation [key] = 'anything';
Comments
Post a Comment