setProperties(obj, properties);
// If an initialize function was passed as the last argument, execute
// it now. The fields of the result of the function are then injected
// into the object after, if it is a NativeObject.
if (initialize != null) {
Object res = initialize.call(cx, scope, obj, args);
if (res instanceof NativeObject)
setProperties(obj, (NativeObject) res);
}
return obj;
}