我正在編寫腳本語言,但是我需要幫助確定一些語法。我主要是在決定兩件事情時遇到問題。哪個更適合數組的語法?
首先,調用數組中的部件的語法。我正在考慮兩種選擇之一,但如果你願意的話,給我一些建議。
比方說,我有一個數組在Javascript中可表示爲
var people = [
["Joe",34],
["Bill",29],
["Steve",36]
];
的選項
Option One
people[2][1]
returns 36
Option Two
people[2,1]
returns 36
二,語法調用函數。我正在考慮兩種選擇之一,但如果你願意的話,給我一些建議。
比方說,我有一個在Javascript將表示一個功能
function foo(bar,hi) {
return bar;
}
的選項
Option One
The same as Javascript
example:
function foo(bar,hi) {
return bar
}
Option Two
The same as Javascript, but
- separating each private variable with it's own set of parentheses
- no need to state "function" in front
example:
foo(bar)(hi){
return bar
}
Option Three
The same as Javascript, but
- a colon to separate the namespace from the private variables
- no parentheses due to the lack of need
example:
foo:bar,hi{
return bar
}
任何和所有的意見和建議將是非常有幫助!我希望你們能夠提出一些很好的想法來做到這一點,並且請爲語法提供任何建議。我仍然需要其他一些幫助,但這些並不是什麼大的決定。
在此先感謝!