首頁 > 易卦

話說前端27-條件語句

作者:由 LearningYard學苑 發表于 易卦日期:2023-01-13

ppt怎麼批次刪除幻燈片

話說前端27-條件語句

話說前端27-條件語句

話說前端27-條件語句

01:42

未知來源

分享興趣,傳播快樂,增長見聞,留下美好!

親愛的您,這裡是LearningYard新學苑。

今天小編為大家帶來話說前端27-條件語句歡迎您的訪問。

Share interests, spread happiness, increase knowledge, and leave a good legacy!

Dear you, this is The LearningYard Academy.

Today Xiaobian brings you the knowledge sharing of management principles (7): Crowd Relationship Theory (Mayo's Huasang experiment), welcome to your visit.

if/else 語句在指定條件為真時執行程式碼塊。如果條件為假,則可以執行另一程式碼塊。

if/else 語句是 JavaScript 的“條件”語句的一部分,用於根據不同的條件執行不同的操作。

在 JavaScript 中,我們有以下條件語句:

The f/else statement executes the code block when the specified condition is true。 If the condition is false, another code block can be executed。

If/else statement is a part of JavaScript‘s “conditional” statement, which is used to perform different operations according to different conditions。

In JavaScript, we have the following conditional statements:

使用 if 指定要執行的程式碼塊,如果指定條件為真

使用 else 指定要執行的程式碼塊,如果相同條件為假

如果第一個條件為假,則使用 else if 指定要測試的新條件

使用 switch 選擇要執行的多個程式碼塊之一

Use if to specify the code block to be executed, if the specified condition is true

Use else to specify the code block to execute, if the same condition is false。

If the first condition is false, use else if to specify the new condition to be tested。

Use switch to select one of multiple code blocks to execute。

if 語句指定在條件為真時要執行的程式碼塊,

else 語句指定在條件為假時要執行的程式碼塊,

如果第一個條件為假,則 else if 語句指定一個新條件:。

特殊使用,切換圖片:

If statement specifies the code block to be executed when the condition is true, else statement specifies the code block to be executed when the condition is false, and if the first condition is false, else if statement specifies a new condition:。

Use special, switch pictures:

if

(image。

src

match

“bulbon”

)) {

image。

src

=

“pic_bulboff。gif”

}

else

{

image。

src

=

“pic_bulbon。gif”

}

其中image。src就是圖片的地址。

第二:swich為多選項進行執行:

switch

(表示式) {

case

n

程式碼塊

break

case

n

程式碼塊

break

default

預設程式碼塊

}

程式碼解釋:

計算一次 switch 表示式

把表示式的值與每個 case 的值進行對比

如果存在匹配,則執行關聯程式碼

Code interpretation:

Calculate the switch expression once

Compare the value of the expression with the value of each case

If there is a match, execute the associated code。

今天的分享就到這裡了。如果您對今天的文章有什麼獨特的想法,歡迎評論留言,讓我們相約明天,祝您今天過得開心快樂!

That's it for today's sharing. If you have any unique ideas for today's article, please leave a comment, let us meet tomorrow, I wish you a happy day!

參考教程:w3school

翻譯:Google翻譯

本文由LearningYard新學苑原創,部分圖片文字來自網路,如有侵權請聯絡。

文字&排版|李仕陽

稽核|李煥