在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,else if and end Lua
- 2. if and else in Aurelia.js
- 3. If/Else and typeof problems
- 4. If-else and self question
- 5. Javascript IF/Else and performance
- 6. if and else not working
- 7. If else and switch statment
- 8. if-else vs if-else-if-else
- 9. if/if else/else
- 10. if else condition with and operator
- 11. Python 3 and-or vs if-else
- 12. if [true] and [true] then .... else .... batch
- 13. Javascript「if and else」語句
- 14. If and Else help;蟒蛇
- 15. if and else does not work
- 16. If/else with button and input
- 17. if else else if sql
- 18. Javascript if if else else
- 19. 「if else」in php when「if」and「else」have same action
- 20. 如何在PROLOG中執行序列「If,Else If and Else」?
- 21. if/else if/else menu issue c
- 22. if else if else語句(JS)
- 23. getElementById.innerHTML if if else
- 24. if if else
- 25. Javascript if if else always return to 2 else if
- 26. if else if else in angular js
- 27. jQuery if if else else filter
- 28. 嵌套if-else vs if-else?
- 29. jQuery/Javascript if if contains else else
- 30. If Else If Else sort XSLT1.0
不,它不 – Phil 2012-03-21 06:29:53