0
我使用JSLint的皮棉到下面的代碼對象錯誤:的JSLint
'use strict';
var mathService = {
add: add,
subtract: subtract,
multiply: multiply,
divide: divide,
power: power,
squareRoot: squareRoot
};
function add(first, second) {
return first + second;
}
function subtract(first, second) {
return first - second;
}
function multiply(first, second) {
return first * second;
}
function divide(first, second) {
return first/second;
}
function power(first, second) {
return Math.pow(first, second);
}
function squareRoot(first) {
return Math.sqrt(first);
}
當我嘗試皮棉這個代碼,我得到了我的對象表明它是未定義的每個屬性的錯誤消息。但是,我不認爲必須定義對象屬性?先謝謝您的幫助!
什麼是確切的錯誤信息?我假設它抱怨功能是在它們被定義之前分配的。 – JJJ
請注意,錯誤是指在對象定義中冒號的_right_項 - 屬性名稱本身沒有問題。如果您更改屬性或函數名稱以使它們不同,則可以看到此錯誤 - 錯誤指向右側。 –
感謝您的幫助!幸運的是,克萊德洛博的代碼完成了這個訣竅。 –