JS simulation expands C # LINQ expressions to share LINQ to JS

Source: Internet
Author: User

Hi: The following is a LINQ to JS share, if there is a coincidence is purely coincidental

(function () {Array.prototype.first = function (predicate, def) {var l = this.length; if (!predicate) return l? This[0]: def = = null?        Null:def;        for (var i = 0; i < L; i++) if (predicate (this[i], I, this)) return this[i]; return def = = null?    Null:def;    }; Array.prototype.where = Array.prototype.filter | |        function (predicate, context) {context = context | | window;        var arr = [];        var L = this.length;        for (var i = 0; i < L; i++) if (Predicate.call (context, this[i], I, this) = = = True) Arr.push (This[i]);    return arr;    }; Array.prototype.select = Array.prototype.map | |        Function (Selector, context) {context = context | | window;        var arr = [];        var L = this.length;        for (var i = 0; i < l; i++) Arr.push (Selector.call (context, this[i], I, this));    return arr; };}) ();

How to use: List.first (function (t) {return T.value.trim () = = City.trim ();});

  

JS simulation expands C # LINQ expressions to share LINQ to JS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.