functions with same names in javascript

Posted by biju on Stack Overflow See other posts from Stack Overflow or by biju
Published on 2010-05-26T09:40:41Z Indexed on 2010/05/26 9:51 UTC
Read the original article Hit count: 241

Filed under:
|
|

Hi, I tried to write a function on a js file and another function with the same name in the page.I expected an error but no error came and i got only the function from the js file to execute.How is this possible.Even if i write a function in a separate js file,everything is rendered in a single html file.Then how come it is possible

<script type="text/javascript" language="javascript" src="JScript.js" />
<script language="javascript">
    function Boo()
     {
        alert("Hai new");
    }
</script>

<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:Button runat=server OnClientClick="Boo();" Text="Click" />
    </div>
    </form>
</body>

and in the js file

function Boo() {
    alert("Hai");
}

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about JavaScript