javascript中範圍,優先順序等等問題, 求助中。。。。。。。。

來源:互聯網
上載者:User
HTML code
<html><head><title>Untitled Page</title></head><body><!--指令碼塊1--><script>alert(a);//undefined             第一個Avar a="dd";alert(a);//dd                   第二個A</script><!--//指令碼塊2--><script>alert(a);//function a(){}              第三個Avar a=function a(){};alert(a);//function a(){}                  第四個A</script><!--指令碼塊3--><script>alert(a);//function a(){}                      第五個Avar a=function(){};alert(a);//function(){}                       第六個A</script><script>/*******************************************************關於以上的不解點。在上述中我只用了一個a,彈出的結果寫在了注釋後面問題1:*********為什麼第三個A不是彈出[dd],而第五個A彈出[function a(){}],也就是說,第三個沒有延續  [指令碼塊1],而第五個就延續  [指令碼塊2]**********問題2:***********它的執行順序是怎樣的。。每個指令碼塊它們為什麼不同。。***********問題3***************當我將它們合為一個指令碼塊裡。為什麼結果變了呢?//<script>alert(a);//function a(){}             第一個Avar a="dd";alert(a);//dd                          第二個Aalert(a);//dd                           第三個Avar a=function a(){};alert(a);//function a(){}                  第四個Aalert(a);//function a(){}                      第五個Avar a=function(){};alert(a);//function(){}                       第六個A<!--</script>--> 注意其中,第一個A變了,還有第三個A也變了。與分成各個指令碼塊有什麼不同嗎??  ***************  問題4

***************
額外的一個問題:當我這樣定義了一個指令碼時。
var bi=function(){  this.aa=1;
this.aa=2;}bi.prototype.aa=3;
var bi=new bi();
alert(bi.aa); //2 ---->彈出是2


問題是。為什麼原型屬性a沒有去覆蓋i內部的aa屬性呢。
而aa內部的屬性可以被覆蓋就是說。為什麼彈出的結果不是3呢??
有可能得到3嗎?***************

********************************************************/</script></body></html>
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.