switch 语句

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>DEMO - Lik</title>
</head>
<body>
	<script>
		var total = 10;
		switch(total){
			case 0:
				console.log('这是个0');
				break;
			case 10:
				console.log('这是个10');
				break;
			case 20:
				console.log('这是个20');
				break;
			default:
				console.log('它什么都不是');
		}
	</script>
</body>
</html>

  最后控制台会输出:

 

posted @ 2017-07-09 16:34  likwin  阅读(136)  评论(0编辑  收藏  举报