zoukankan      html  css  js  c++  java
  • ECMAscript之if..else语句,for循环,while循环,switch,case语句,异常处理

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>if else语句</title>
    </head>
    <body>
    <script>
    // 1.if else语句
    // a='star';
    // if(a=='star'){
    // alert('ok');
    // }else{
    // alert('no');
    // }
    //2.if else语句
    // a='star';
    // if(a=='star') {
    // alert('ok');
    // }else if(a=='sun'){
    // alert('no');
    // }else{
    // alert('123');
    //}
    //3.switch case 语句
    // var x=3;
    // switch (x){
    // case 1:y='lai';break;
    // case 2:y='tong';break;
    // case 3:y='xing';break;
    // default:y='none';
    // }
    // alert(y)
    //4.for循环控制语句1
    // var a=[1,true,'star']
    // for(var i in a){
    // console.log(i);
    // console.log(a[i]);
    // }
    //for循环控制语句2
    // for(var i=0;i<=5;i++){
    // console.log(i);
    // }
    //(2)
    // var sum=0;
    // for(var i=1;i<=100;i++){
    // sum+=i;
    // }
    // alert(sum);5050
    // (3) for(var i=1;i<=6;i++){
    // document.write('<h'+i+'>hello</h'+i+'>')
    // document.write('<br>')
    // }
    // obj={"1":"star","2":['lat',1,"2"]}
    // alert(typeof(obj))//object
    // alert(obj);//[object Object]
    // for(var i in obj){
    // console.log(i);
    // console.log(obj[i]);
    // }
    //5 .while循环
    //1+2+.....100
    // var i=1,sum=0;
    // while (i<=100){
    // sum+=i;
    // i++;
    // }alert(sum)
    //6.异常处理
    // (1)try{
    //
    // }catch(e){
    //
    // }
    // finally {
    //
    // }
    //(2)主动抛出异常
    // throw Error('error')

    </script>

    </body>
    </html>
  • 相关阅读:
    索引的优缺点
    php中创建和调用WebService
    Redis常用数据结构和操作
    PHP的array_merge
    数据库最左前缀原则
    Mysql+Sphinx实现全文搜索
    YAPI安装和使用
    根据导入xlxs的文件,来写入数据库
    操作RDS文档说明
    springboot查找配置文件路径的过程
  • 原文地址:https://www.cnblogs.com/startl/p/12234874.html
Copyright © 2011-2022 走看看