zoukankan      html  css  js  c++  java
  • 2020/12/15

    通常在写代码时,您总是需要为不同的决定来执行不同的动作。您可以在代码中使用条件语句来完成该任务。

    在 JavaScript 中,我们可使用以下条件语句:

    • if 语句 - 只有当指定条件为 true 时,使用该语句来执行代码
    • if...else 语句 - 当条件为 true 时执行代码,当条件为 false 时执行其他代码
    • if...else if....else 语句- 使用该语句来选择多个代码块之一来执行
    • switch 语句 - 使用该语句来选择多个代码块之一来执行

    请使用 if....else 语句在条件为 true 时执行代码,在条件为 false 时执行其他代码。

    语法

    if (condition)
    {
        当条件为 true 时执行的代码
    }
    else
    {
        当条件不为 true 时执行的代码
    }
  • 相关阅读:
    列表和元组
    UVM宏
    UVM中重要函数
    组合模式(composite)
    装饰器模式(Decorator)
    适配器模式(Adapter)
    桥接模式
    原型模式(prototype)
    单例模式(singleton)
    UML类图
  • 原文地址:https://www.cnblogs.com/qiangini/p/14162315.html
Copyright © 2011-2022 走看看