I'm exploring some code and I saw the practice of embedding one constructor function into another used many times:
/**
* @constructor
*/
function contact_duplicates_manager(global_objects)
{
this.field_processors =
{
"Phone1Number": new phone_processor(),
"Phone2Number": new phone_processor(),
"Phone3Number": new phone_processor()
}
//...here some other code
/**
* @constructor
*/
function phone_processor()
{
//...here some other code
function clear_phone(phone)
{
//...here some code
}
this.is_equals = function (value1, value2)
{
return is_equals(clear_phone(value1), clear_phone(value2));
}
}
}
//... later in the code
var valid = this.field_processors[fld_name]["is_equals"](native_value, custom_value)
Do you think phone_processor
constructor function should be outside contact_duplicates_manager
?