Is it possible to do in jquery something similar to this C# example:
LoopModel = Model.Fields
.Where(p => p.Key < 1000 && !Model.FieldHandled.ContainsKey(p.Key) && !FieldsValid.ContainsKey(p.Key))
.OrderBy(p => p.Value.SortOrder).ThenBy(p => p.Value.FieldTypeID).ThenBy(p => p.Value.FieldLabel);
I can do
var fields = @Html.Raw(JsonConvert.SerializeObject(Model.Fields));
So I want to be able to select certain fields from "fields".
Thanks
Use filter. No libraries required.
Here is an example from the link:
const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];
const result = words.filter(word => word.length > 6);
console.log(result);
// expected output: Array ["exuberant", "destruction", "present"]
I prefer Lodash or Underscore. They are widely used in various JS libs and right now I think they are the most JavaScript-ish solution. They also guarantee support for legacy browsers, having lots of performance enhancements. I think it's worth to learn them.
https://lodash.com/ http://underscorejs.org/
See the comparison here: Differences between lodash and underscore
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With