ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
#### 变量字面量声明 --- - 必须使用关键字 var, (ES6使用 let / const ),严禁在不使用关键字时声明一个变量; - 基础类型的声明推荐使用字面量的形式,而非构造函数形式; - 如果一次需要声明多个变量,推荐使用一次关键字声明,英文标准逗号进行分割; > <span class="do">正确实践:</span> ```js //一次声明多个变量 var a = 1, b = 2, c = "hello wolrd"; //字面量形式 var student = { name : "Jack", age : 19, sexy : 0 level : 2 }; var colors = ["red","yellow","pink","green"]; //ES6 let pets = {}; const greetingWords = "greeting! My friend!"; ``` > <span class="dont">错误实践:</span> ```js var a = 1; var b = 2; var c = "hello world"; var student = new Object(); student.name = "Jack"; student.age = 19; var colors = new Array("red","yellow"); let pets = new Object(); const greetingWords = new String("greeting! My friend!"); ```