Js第二天知识点打卡

105 阅读1分钟

今日知识点:

  1. 算术运算符

"+ - * / %" 加 减 乘 除 取模

其中取模运算符可以取余,判断奇偶或倍数

x++ 加号在前 先加再返回
++x 加号在后 先返回后加

2.赋值运算符 += -+ *= /=

3.比较运算符

> < == ===


4.逻辑运算符 && || ! 与或非

5.三目运算符(条件运算符) 条件 ? 为真的时候的表达式的返回值 : 为假的时候的表达式的返回值
// 字符串拼接 var x = 5; console.log(x + 5); console.log(x + "5");

  var y = "hello";
  console.log(y + "xxx");
  console.log(y + 10);

  console.log(y - 10); // NaN   not a number非数也是数值<br>
console.log(typeof 10);
  console.log(typeof NaN);
  console.log(typeof "10");
  console.log(typeof true);
  console.log(typeof undefined);

  console.log(typeof null);
  console.log(typeof [1, 2, 3]);
  console.log(typeof { name: "nick" });


 // for (var i = 1; i <= 9; i++) {
    //     var str = ''//将上一次内部传出来的str清空
    //     for (var j = 1; j <= i; j++) {
    //         str += j + 'x' + i + '=' + i * j + '\t';
    //     }
    //     console.log(str);
    //     // str = str + '\n';
    // }

image.png

image.png

image.png