loop through array in ES5

If you’re using an environment that supports the Array features of ES5 (directly or using a shim), you can use the new forEach function: var a = [“a”, “b”, “c”]; a.forEach(function(entry) { console.log(entry); }); forEach accepts an iterator function and, optionally, a value to use as this when calling that iterator function (not used above). The iterator function is called for each…

angularjs filter on array

Use property in input’s ng model Filter is used for selecting a subset of a give array. The requirements for a filter are an array to be filtered and the predicate based on which the array need to be filtered. The predicate could be as simple as a string and let’s try filtering using a…

reduce function for array in javascript

Parameters callback Function to execute on each value in the array, taking four arguments: previousValue The value previously returned in the last invocation of the callback, or initialValue, if supplied. (See below.) currentValue The current element being processed in the array. index The index of the current element being processed in the array. array The…

javascript array in depth

What is an Array in JavaScript? A numerically indexed map of values. Traditionally an array reserves a continuous allocation of memory of predefined length. In JavaScript this is not the case. A JavaScript array is simply a glorified object with a unique constructor and literal syntax and an additional set of properties and methods inherited…

java vs c++

At the beginning of a new project, you may be faced with the question, “Should I use C++ (or some other language) for my next project, or should I use Java?” As an implementation language, Java has some advantages and some disadvantages over other languages. One of the most compelling reasons for using Java as…