官术网_书友最值得收藏!

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"); 
} 
主站蜘蛛池模板: 额尔古纳市| 泽库县| 垣曲县| 天祝| 彰武县| 缙云县| 兴隆县| 内丘县| 临城县| 马边| 横山县| 景洪市| 卢湾区| 呼和浩特市| 克什克腾旗| 绥德县| 洛阳市| 无为县| 阳城县| 陕西省| 福清市| 长岭县| 天水市| 合川市| 扎鲁特旗| 博野县| 板桥市| 邹城市| 巧家县| 门头沟区| 得荣县| 门头沟区| 商水县| 贡嘎县| 东乡族自治县| 兰溪市| 隆昌县| 彰化市| 嘉义市| 措勤县| 宜川县|