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

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"); 
} 
主站蜘蛛池模板: 万荣县| 务川| 四川省| 汾西县| 石狮市| 湄潭县| 沐川县| 钟祥市| 宿州市| 府谷县| 信阳市| 沈阳市| 彰化县| 邹平县| 徐水县| 崇仁县| 黔东| 鹰潭市| 巴林右旗| 南乐县| 佛山市| 建平县| 内乡县| 凭祥市| 石景山区| 龙口市| 沐川县| 壤塘县| 深泽县| 鄂托克旗| 双城市| 栾川县| 邵武市| 仙游县| 沾化县| 宝坻区| 林芝县| 东安县| 枞阳县| 同心县| 遂宁市|