在Javascript中,如果您有If ... Else If ... Else If ... Else情況,計算機會繼續檢查下一個項目,前提是是否觸發了其他項目。例如。如果第一個「If」語句爲真並且代碼執行,它是否仍然嘗試檢查「Else If」或「Else」的條件?If and Else If Execution
1
A
回答
5
沒有它不會檢查,如果由於您使用否則,如果條件爲真 如果
相反,如果你要是如果要是那麼所有的if語句將被執行
7
假設你有一個代碼段使用
if(a)
func1()
else if(b)
func2()
else if(c)
func3()
else
func4();
//next statement
如果a
爲真func1()
將被調用,並且在它返回後,控件將轉到下一個語句。
因此,如果b
爲真,那麼最初將調用func2()
,然後在返回後,控件將轉到下一個語句。
func4()
將被調用如果a
,b
,c
所有這些都是錯誤的。 func4()
返回控制之後去下一個語句。
相關問題
- 1. If/Else and typeof problems
- 2. if and else in Aurelia.js
- 3. if-else vs if-else-if-else
- 4. if/if else/else
- 5. if [true] and [true] then .... else .... batch
- 6. if else condition with and operator
- 7. If and Else help;蟒蛇
- 8. Javascript「if and else」語句
- 9. If/else with button and input
- 10. if else else if sql
- 11. Javascript if if else else
- 12. 「if else」in php when「if」and「else」have same action
- 13. if else if else語句(JS)
- 14. getElementById.innerHTML if if else
- 15. if else if else in angular js
- 16. 嵌套if-else vs if-else?
- 17. jQuery if if else else filter
- 18. sys.stdin.readline()if if else(Python)
- 19. if/else或double if?
- 20. 的if else與AND,OR在Excel
- 21. if elif else construct and full DRY conform
- 22. SAS if-else if not working
- 23. if,else if和else聲明? java
- 24. 如何提高我的「if and else if」VBA?代碼
- 25. T-SQL IF-ELSE
- 26. Python(if,else,elif)
- 27. javascript - 如何控制if/else if/else
- 28. 調試器行爲在if,else if,else
- 29. if if else else does not work php
- 30. for循環if if else else批號
不,它不 – Phil 2012-03-21 06:29:53