I am trying to return the name of the variable to which the function is assigned.
I gave an example below. The end result, I would like to modelPerson.title()return the name of the variable title.
For example, I have the following code:
Definition of basic model types
var types = {
string: function() {
return function() {
return "I want this to return 'title'";
}
}
};
Using model types
var modelPerson = {
title: types.string(),
firstName: types.string(),
surname: types.string(),
position: types.string()
};
Attempt to return the title
console.log(modelPerson.title());
Sorry if this is a bit unclear. I have included JSFiddle if this helps:
http://jsfiddle.net/4f6VE/
Thanks for any help you can give.
source
share