How come eval does not work under nodejs?
function show(myVariable) {
var myValue = eval(myVariable);
console.log(myVariable + "=" + myValue);
}
var foo = "bar";
show("foo");
on a HTML page this returns foo=bar
in the console log
in a nodejs controller it gives SyntaxError: Invalid or unexpected token
This is the original code:
"use strict";
var mongoose = require('mongoose');
function show(myVariable) {
var myValue = eval(myVariable);
console.log(myVariable + "=" + myValue);
}
exports.messageSave = function(req, callback) {
var foo = "bar";
show("foo");
return
// a lot of other code below, but put return to focus on the problem
}
UPDATE
What I am trying to do here is for my show
function to read the name of the variable that was parsed to it.