Hello! 欢迎来到小浪资源网!

jsBasics_Practice


jsBasics_Practice

基础知识

下面列出的这些变量的类型是什么?使用 typeof 验证这一点并将结果输出到控制台:

let str1 = 'laurence'; console.log(typeof (str1));   //string let str2 = "svekis"; console.log(typeof (str2));  //string let val1 = undefined; console.log(typeof (val1));  //undefined let val2 = null; console.log(typeof (val2));  //object let mynum = 1000; console.log(typeof (mynum)); //number 

下面的变量是什么数据类型

const c = "5"; //string const d = 91;  // number 

一般来说,1号线和2号线哪个更好?

let empty1 = undefined; //line 1 let empty2 = null; //line 2 

下面的控制台输出是什么?

let a1 = "hello"; a1 = "world"; console.log(a1);  //world 
let a2 = "world"; let b2 = hello ${a2}!; console.log(b2);  // helloworld 

价值是多少..?

let a4 = 5; let b4 = 70; let c4 = "5"; b4++; console.log(b4);  //71 

令结果 = 3 4 * 2 / 8; // 4,不打印任何内容,因为我们没有记录结果。

let firstnum = 5; let secondnum = 10; firstnum++; secondnum--; let total = ++firstnum + secondnum; console.log(total);  //16 let total2 = 500 + 100 / 5 + total--; console.log(total2);  // 536 
const a = 5; const b = 10; console.log(a > 0 && b > 0);  // true console.log(a == 5 && b == 4);  // false console.log(true || false);  // true console.log(a == 3 || b == 10);  // true console.log(a == 3 || b == 7);  // false 

创建一个数组作为您的购物清单,其中包含 3 种商品:“牛奶”、“面包”和

苹果”。在控制台中检查列表长度。将“面包”更新为“香蕉”。将整个列表输出到控制台。

相关阅读