<Case 1:textBox>

int[] testArray = new int[] { 10, 7, 1, 2, 3 };
for (int i = 0; i <testArray.Length ; i++)
{
txtBox3.Text = testArray[i].ToString() + “ Now is: “ + i.ToString();
}

Result:

3 Now is: 4

<Case 2:MessageBox>

int[] testArray = new int[] { 10, 7, 1, 2, 3 };
for (int i = 0; i <testArray.Length ; i++)
{
MessageBox.Show(testArray[i].ToString() + “ Now is: “ + i.ToString());
}

Result:

10 Now is: 0

7 Now is: 1

1 Now is: 2

10 Now is: 3

3 Now is: 4

Meanwhile for those want to know array item via for loop .

Have to aware the result IS DIFFERENT!

This article explain what different between Arrow Function in JavaScript

Part 1 Not Defined

<script>

console.log(a);

</script>

會出現"Not defined" 表示該variable未被定義即使用

Part2 undefined

var a;

console.log(a);

會出現”undefined” ,表示variable未指定變數

但若是

console.log(a);

var a = 5

依然會出現 undefined,是因為在JS 中並不向其它語言諸如C# , JAVA屬於line by line ,也就是即便 console.log(a); 前並未宣告 a 但 a已生成 只是未被指定變數5 就要輸出了,所以出現undefined。

那麼如標題所述,已知

<情境一>

使用一般function的 getAge 方法

var emp1 = createEmployee(“Mary”, 30);

TING-YU,CHANG

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store