How can I replace a javascript for loop with a forEach and get access to the index for each iteration? -


मुझे यह जावास्क्रिप्ट है:

  factory.remove = function (arr, property, num) ) {For (var i = arr.length - 1; i> gt; = 0; -i) {यदि (एआरई [i] [प्रॉपर्टी] === संख्या) arr.splice (i, 1); }};   

क्या कोई मुझे बता सकता है कि मैं कैसे लूप के लिए एक का उपयोग कर सकता हूं। इसके बजाय इसके लिए हर जगह? मैं किस बारे में निश्चित नहीं हूँ, किस प्रकार के बारे में है, मैं किसके लिए i का उपयोग कर सकता हूं? इसके अलावा अगर मैं प्रत्येक का उपयोग करता हूं तो क्या मैं उस सरणी का एक टुकड़ा कर सकता हूं या यह संभव नहीं है?

< P>

इस तरह से लिखा जा सकता है

  arr.forEach (फ़ंक्शन (elem, index) {if (elem [property] === num) arr .splice (सूचकांक, 1);})    

Comments

Popular posts from this blog

php - how to change mysql_result($res, 0, "url"); to mysqli -

Delphi: missing interface declarations for UI Automation methods -

android - How to attach an image from an app to gmail -