Decision support statements
An if/else statement in JavaScript and other programming languages is a control statement that allows for decision-making in your code. This type of statement performs a test based on an expression, that you specify at the top of the statement. If the test returns a value of true then the statements associated with the if block will run. If the test returns a value of false then the execution skips to the first else if block. This pattern continues until a value of true is returned in the test or the execution reaches the else statement. The following code example shows how this statement works:
var layerName = 'streets'; if (layerName == 'aerial') { alert("An aerial map"); } else if (layerName == "hybrid") { alert("A hybrid map"); } else { alert("A street map"); }
推薦閱讀
- Visual FoxPro程序設計教程(第3版)
- SoapUI Cookbook
- Instant QlikView 11 Application Development
- HTML5+CSS3+JavaScript Web開發案例教程(在線實訓版)
- Go并發編程實戰
- Python極簡講義:一本書入門數據分析與機器學習
- Unity Character Animation with Mecanim
- Clojure Polymorphism
- 你真的會寫代碼嗎
- 基于Docker的Redis入門與實戰
- Python數據分析與挖掘實戰(第2版)
- Python量子計算實踐:基于Qiskit和IBM Quantum Experience平臺
- Learning Yeoman
- Java程序員面試筆試真題庫
- Mastering Apache Cassandra(Second Edition)