I believe intellisense can solve a lot of time and errors. Lets say that I am making an ajax call and I know that I will get an array of cars.
$.ajax({ type: "POST", url: "GetCars.aspx", success: function (cars) { for(var i = 0; i < cars.length; i++) { var car = cars[i]; if(document.designMode) { car = { type: "", model: 0, colors: new Array() }; }
I need something that will return true in the visual studio editor and false in the browser. if(document.designMode) returns true in VS and in the browser, therefore the line car = { type: "", model: 0, colors: new Array() }; always executed. I do not want the string car = { type: "", model: 0, colors: new Array() }; executed in browser only on VS, so I get intellisense . How can i do this?
Decision
Thanks @Shoms I came up with:
var car = null; if (window.navigator.userAgent.length === 212) { car = { type: "", model: 0, colors: new Array() }; }
Please note that your VS may need a different number. For me, I should try> 500, then 250, 125, etc., Until I find that it is a length of 212.
source share