Posted inJavascript
A quirky way to dynamically set key/value pairs in Javascript
There are many instances where one might want to iterate over an array and keep track of of the frequency in which an element appears (think finding palindromes). Using JavaScript's logical OR ( || ) operator is a great way to do this.