变量名:自己根据规则给变量起的一个名字。
关键字:关键字用于执行特定操作的一类字符。按照规则,关键字也是语言保留的,不能用做标识符。
比如 if else 这些 就是关键字
abstract | enum | int | short |
boolean | export | interface | static |
byte | extends | long | super |
char | final | native | synchronized |
class | float | package | throws |
const | goto | private | transient |
debugger | implements | protected | volatile |
double | import | public |
|
undefined 和 null 是否是 关键字?
答案: undefined严格意义来说不是关键字,是属于变量。 null 是属于关键字的。
// let null = '111';
// console.log(null) //Uncaught SyntaxError: Unexpected token null 未捕获的SyntaxError:意外的令牌null
// Unexpected token 表示语法错误 所以是关键字
// console.log(if) //Uncaught SyntaxError: Unexpected token if
// if是关键字 显示的错误和 null 是一样。
// let undefined = '111';
// console.log(undefined) //Uncaught SyntaxError: Identifier 'undefined' has already been declared 未捕获的SyntaxError:标识符“undefined”已经声明
// 表示是已经声明过不能重复声明
// const a = 1;
// const a =2;
// console.log(a) //Uncaught SyntaxError: Identifier 'a' has already been declared
// 是一个错误代表 undefined为变量
这两个网站有给我提示:
https://www.cnblogs.com/qdjl/p/9241947.html?tdsourcetag=s_pcqq_aiomsg
https://blog.csdn.net/nanruitao10/article/details/50878198