Javascript doesn’t have foreach statement, but it’s simple to emulate one: <script type="text/javascript"> var arr = [’one’, ‘two’, ‘three’, ‘four’, ‘five’, ‘etc’]; for (var i in arr) { var element = arr[i]; alert(i + ‘: ‘ + element); } </script> It’s actually equivalent of foreach in other languages like PHP. …

Another analog of PHP’s function that obviously doesn’t work in Javascript is str_replace. Javascript has simple method of String object called “replace()”. Using of this method is very trivial: var string = "another day on the Earth!"; string.replace(’another’, ‘new’); alert(string); There is one problem – this method replaces only first …