for (var property in object) { if (object.hasOwnProperty(property)) { // do stuff } }
Source: http://stackoverflow.com/questions/8312459/iterate-through-object-properties
Bruce Ng's software development blog
An archive of solutions of programming problems I have faced in my career
for (var property in object) { if (object.hasOwnProperty(property)) { // do stuff } }
Source: http://stackoverflow.com/questions/8312459/iterate-through-object-properties
The example processes values read by EPPlus, might be useful in other situations, too.
public DateTime GetDate(object valFromExcel)
{
if(valFromExcel is DateTime) return valFromExcel;
if(valFromExcel is double) return DateTime.FromOADate((double)valFromExcel);
return Convert.ToDateTime(valFromExcel);
}
//if the namespace has already been declared, use the existing one, otherwise create an empty object
//for the namespace
var theNamespace = theNamespace | {};
//assign functions and objects in the namespace by setting properties.
theNamespace.aFunction = function(){};
Using namespace will help avoid functions with same name being overridden by each other.
var context = new SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists().getByTitle(listTitle);
var listItem = list.getItemById(listItemId);
context.load(listItem);
context.executeQueryAsync(
function() {
var workflowStatusField = listItem.get_parentList().get_fields().getByTitle(workflowTitle); //get workflow status field
var workflowStatusValue = listItem.get_item(workflowTitle); //get workflow status field value
success(workflowStatusValue);
},
error
);
var items = SP.ListOperation.Selection.getSelectedItems(ctx);