Is there any difference between  &lt;a href="javascript:void(0)"&gt;Link&lt;/a&gt; &lt;asp:Button ID="btn" runat="server" OnClientClick="return Function()" OnClick="btn_Click" Text="Button" /&gt;   and  &lt;a href="javascript:void(0);"&gt;Link&lt;/a&gt; &lt;asp:Button ID="btn" runat="server" OnClientClick="return Function();" OnClick="btn_Click" Text="Button" /&gt;   ?  (The ; after the JavaScript is the difference - does this have any effect on any specific browsers or anything?)
13680
In many situations, JavaScript parsers will insert semicolons for you if you leave them out. My question is, do you leave them out?  If you're unfamiliar with the rules, there's a description of semicolon insertion on the . Here's the key point:     If the first through the nth tokens of a JavaScript program form are grammatically valid but the first through the n+1st tokens are not and there is a line break between the nth tokens and the n+1st tokens, then the parser tries to parse the program again after inserting a virtual semicolon token between the nth and the n+1st tokens.   That description may be incomplete, because it doesn't explain @Dreas's example. Anybody have a link to the complete rules, or see why the example gets a semicolon? (I tried it in JScript.NET.)   is related, but only talks about a specific scenario.
67914
I am creating an element with document.createElement(). Now how can I pass it to a function that only takes a Jquery object?  $("#id")    I can not use it, as the element has not been rendered in the page yet.
118972
I have been using ASP.NET for years, but I can never remember when using the # and = are appropriate.  For example:  &lt;%= Grid.ClientID %&gt;   or  &lt;%# Eval("FullName")%&gt;   Can someone explain when each should be used so I can keep it straight in my mind? Is # only used in controls that support databinding?
21847
Given a function:  function x(arg) { return 30; }   You can call it two ways:  result = x(4); result = new x(4);   The first returns 30, the second returns an object.  How can you detect which way the function was called inside the function itself?  Whatever your solution is, it must work with the following invocation as well:  var Z = new x();  Z.lolol = x;  Z.lolol();   All the solutions currently think the Z.lolol() is calling it as a constructor.
14089
I'm creating a function where I need to pass an object so that it can be modified by the function. What is the difference between:  public void myFunction(ref MyClass someClass)   and  public void myFunction(out MyClass someClass)   Which should I use and why?
52702
As far as I can tell, these two pieces of javascript behave the same way:  Option A:  function myTimeoutFunction() {     doStuff();     setTimeout(myTimeoutFunction, 1000); }  myTimeoutFunction();   Option B:  function myTimeoutFunction() {     doStuff(); }  myTimeoutFunction(); setInterval(myTimeoutFunction, 1000);   Is there any difference between using  and ?
107998
Is it like...  var obj = new Object();  obj.function1 = function(){     //code }   or something like that?
65851
Is there a well-supported, common behavior that I can expect if I do something like this in HTML:  &lt;form method="get" action="/somePage.html?param1=foo&amp;param2=foo"&gt;   &lt;input name="param2"&gt;&lt;/input&gt;   &lt;input name="param3"&gt;&lt;/input&gt; &lt;/form&gt;   Seems like this sort of thing is inherently ridiculous, but I've seen it used here and there and I was wondering what on Earth the expected behavior should be.  Are browsers smart enough to tack on "&amp;param2=whatever&amp;param3=whatever" to the action, or do they just throw in a second question mark?  Or what?  Are there cases where this is actually the right way to do things?
71962
I have an element with an onclick method.  I would like to activate that method (or: fake a click on this element) within another function.  Is this possible?
33995
I am confused about hreflang="x-default".  I have a site in 2 languages. In each page I have a link to the page itself and a link to the same page in the other language. If I understand correctly, I have to put an x-default also. In my case it goes to the page "language". There the user can see two buttons to choose the language of the site.  The x-default link is the same on all pages and it is present in all of them.   &lt;link rel="alternate" hreflang="en" href="http://example.com/about" /&gt;  &lt;link rel="alternate" hreflang="fr" href="http://example.com/fr/about" /&gt; &lt;link rel="alternate" hreflang="x-default" href="http://example.com/language" /&gt;   I use Screaming Frog to detect possible errors. It says "Missing confirmation links in all the pages" when I see the details of the error. It makes reference only to the x-default link. I do not understand.  How to use the hreflang="x-default"?
7669
What's the difference between JavaScript and Java?
25651
For all major browsers (except IE), the JavaScript onload event doesn’t fire when the page loads as a result of a back button operation — it only fires when the page is first loaded.  Can someone point me at some sample cross-browser code (Firefox, Opera, Safari, IE, …) that solves this problem? I’m familiar with Firefox’s pageshow event but unfortunately neither Opera nor Safari implement this.
12823
In .NET, what is the difference between String.Empty and "", and are they interchangable, or is there some underlying reference or Localization issues around equality that String.Empty will ensure are not a problem?
46209
Using instance methods as callbacks for event handlers changes the scope of this from "My instance" to "Whatever just called the callback". So my code looks like this  function MyObject() {   this.doSomething = function() {     ...   }    var self = this   $('#foobar').bind('click', function(){     self.doSomethng()     // this.doSomething() would not work here   }) }   It works, but is that the best way to do it? It looks strange to me.
8344
I'm working with a bit of html and Javascript code that I've taken over from someone else. The page reloads a table of data (via an asynchronous request) every ten seconds, and then re-builds the table using some DOM code. The code in question looks something like this:  var blah = xmlres.getElementsByTagName('blah'); for(var i = 0; i &lt; blah.length; i++) {     var td = document.createElement('td');     var select = document.createElement('select');     select.setAttribute("...", "...");     select.onchange = function() {         onStatusChanged(select, callid, anotherid);     };     td.appendChild(select); }   When the onchange event is fired for a &lt;select&gt; element however, it seems like the same values are being passed to the onStatusChanged() method for every &lt;select&gt; in the table (I've verified that in each iteration of the loop, callid and anotherid are being given new, distinct values).   I suspect this is occuring because of the nature of how I am setting the event handler, with the select.onchange = function() syntax. If I understand how this is working correctly, this syntax sets a closure for the onchange event to be a function which refers to these two references, which end up having a final value of whatever they are set to on the last iteration of the loop. When the event fires, the value referenced by callid and anotherid is the value set in the last iteration, not the value set at the individual iteration.  Is there a way that I can copy the value of the parameters I am passing to onStatusChanged()?  I've changed the title to better reflect the question and the accepted answer.
42746
Should I use exit() or just return statements in main()? Personally I favor the return statements because I feel it's like reading any other function and the flow control when I'm reading the code is smooth (in my opinion). And even if I want to refactor the main() function, having return seems like a better choice than exit().  Does exit() do anything special that return doesn't?
6080
I'm new to both JavaScript and . In YUI library examples, you can find many uses of this construct:  (function() {     var Dom = YAHOO.util.Dom,     Event = YAHOO.util.Event,     layout = null,         ... })();   I think the last couple of parentheses are to execute the function just after the declaration.  ... But what about the previous set of parentheses surrounding the function declaration?  I think it is a matter of scope; that's to hide inside variables to outside functions and possibly global objects. Is it? More generally, what are the mechanics of those parentheses?