在學習ES6的過程中,一路爬行
errors
1.let命令
{
let a = 'secret';
function f() {
console.log(a);
}
}
f() // 報錯
** Uncaught ReferenceError: f is not defined **
引用錯誤:f 未定義
- ** caught ** 是 ** catch ** 的過去分詞形式,過去式形式
- ** ReferenceError **(引用錯誤,reference:談及,查閱)
- ** defined ** 有定義的;清晰的;
- const 命令
const PI = 3.1415
PI=3;
console.log(PI);
** Uncaught TypeError: Assignment to constant variable **
類型錯誤:指派 常數 為 變量
- ** Assignment ** 指派
- ** constant ** 常數
- ** variable ** 變量;變化的
function constantize(obj){
console.log(obj);
}
constantize({a=1,b=0});
** Uncaught SyntaxError: Invalid shorthand property initializer **
語法錯誤:簡稱的屬性初始化不完整
- ** Syntax ** 語法;句法
- ** Invalid ** 有病的;傷殘的
- ** shorthand ** 簡稱;速記法的;速記
- ** initializer ** 初始化