Posted by Wolfram Kriesing on Wed 19 Nov 23:25
report abuse | download | new post
- var tags = [];
- for (var i=0; i<100000; i++){tags.push({id:i, name:"tag"+i})}
- console.time(1)
- // Approach 1
- //for (var i=tags.length-1; i>=0; i--) if (!tags[i].name.match(/g1/)) { tags.splice(i, 1) }
- // Approach 2
- var newTags = []; for (var i=0, l=tags.length; i<l; i++) if (tags[i].name.match(/g1/)) { newTags.push(tags[i]) }; tags = newTags;
- // Approach 3
- //tags = dojo.filter(tags, "return item.name.match(/g1/) ? index : false")
- console.timeEnd(1)
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.