However, working with ASP.NET, there are times when appending your JS files to the bottom of the page is not an option, especially so when you work with partial views in which your JS functions accepts parameters generated by the application. For example, you have a partial view that accepts some parameters from some other view which is then used in one of your JS functions. But you want to include the jQuery library at the bottom of the page to reduce your initial loading time. However, the function you’ve included in your partial view relies on jQuery being defined before the partial view. So now the script fails because $or jQuery is undefined when the browser hits it. # When not to use the for...in statement So today a colleague of mine ran into a small JavaScript problem. One of his functions ran an Ajax request which returns a JSON object which is parsed using jQuery’s parseJSON method. The resulting array is then ran through another function which does some calculations and displays the results in a list. Here’s where the problem starts. The method that does the calculations runs through the array using the native JavaScript for...in loop, in which a calculation method is applied to every item in the array. However, for some reason, the list contained one extra item with the value NaN. Upon inspecting the array, I found that there was an extra item called map, which was a function. You can probably already guess by now why the calculation didn’t work as it was expected to, and rightly so, especially when the value used in the calculation was a function. # EPiServer CMS: Custom top menu for multiple plugins I’ve been working on this small plugin for EPiServer CMS 6, and I wanted to add it to a custom top menu created by another plugin that I had helped develop. I wanted to append the link for my plugin into the same top menu as that other plugin. The only requirement is that my plugin will still display the same top menu even if the other plugin is not installed. Unfortunately, after a lot of time Googling and forum crawling, I came to the conclusion that it was just not possible to append an item to a top menu dynamically. I didn’t bother looking at solutions that involved me editing the project’s web.config file, which may have helped, since the other plugin already had some code which adds a top menu item to the top menu bar. So I figured I should probably try to use that instead. # Object doesn't support this action - For In Loop and IE I’ve recently encountered a problem in Internet Explorer when I was using a for-in loop in one of my scripts. It was a simple loop too. for (item in data) {$row.data(item, data[item]);
}


This piece of code will attach a data property for each JSON object it receives from an Ajax request. Simple, right? This works in every other browser I’ve tested it on, EXCEPT Internet Explorer.

Turned out the word item is a reserved word or something an IE method, because when I swapped item with something else, like j or _item, the code immediately works.

# Get Nested Property Of An Object

I was working on a small filtering script for a GMaps project, and I needed to create a filtering method to filter markers based on their properties. The catch is, the filtering method has to be able to filter out markers based on several types of properties. Not all at once though.

So obviously I can write a separate method for all the types of filter material required. Every method will grab all the markers on the map, iterate through them, filter out the irrelevant markers, and return the results. But that would result in code duplication, and that’s not how I roll. So instead, I created a single function that handles the filtering, and one method that allows you to get property of nested objects using their property path.