[問題] Global variable
Assigning Values to Undeclared JavaScript Variables
If you assign a value to variable that has not yet been declared, the
variable will automatically be declared as a GLOBAL variable.
This statement:
carname="Volvo";
will declare the variable carname as a global variable , even if it is
executed inside a function.
請教一下,這裡的英文是什麼意思呢?
它是指當指派一個值給尚未被宣告的變數的話,
變數自己會變成全域變數嗎?
那請問…這一行 carname="Volvo"; 怎麼沒有var呢 0.0
它用在什麼地方都行嗎?例如在一個函式裡面這樣打的話,它就會變全域變數了?
(而且不用打var?)
請多指教~ <(__ __)>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.228.120.35
→
10/18 12:58, , 1F
10/18 12:58, 1F
→
10/18 12:59, , 2F
10/18 12:59, 2F
→
10/18 12:59, , 3F
10/18 12:59, 3F
→
10/18 13:00, , 4F
10/18 13:00, 4F
Ajax 近期熱門文章
PTT數位生活區 即時熱門文章
7
20