zoukankan      html  css  js  c++  java
  • JS_Boolean Logic

    • Comparisons
      • >
      • <
      • >=
      • <=
      • ==
      • !=
      • ===
      • !== 
    • == double equals
      • check for equality of value, but not equality of type
      • it coerces both values to the same type and then compares them
      • this can lead to some unexpected results.
        • 0 == ' ';                  //true
        • 0 == false;            //true
        • null == undefined; //true
    • === triple equals.   checks for equality of value and type
      • 2 === '2';        //false
      • false === 0;   //false
      • 10 !== '10' ;   //ture
      • 10 != '10';     //false
    • console.log().  prints arguments to the console
    • Running code from a file
      • write code in a .js file and inculde the script in a .html file(abover the closing body tag)
      • "hi".toUpperCase(); //won't show up in the console
        
        console.log("hi".toUpperCase());   //will show up in the console.
    • conditions
      • if
      • else if
      • else
      • nesting(多种条件语句嵌套)
    • TRUTHY AND FALSY VALUES
      • all js values have an inherent truthyness or falseness about them
      • false values:
        • false
        • 0
        • ''''(empty string)
        • null
        • undefined
        • NaN
      • everything else is truthy!
    • Logical Operations
      • &&.   AND
      • ||.    OR
      • !    NOT
        • ! null            //true
        • ! (0 === 0) //false
        • ! (3 <= 4).  //false
    • How to check a string includes space or not?
    if(string.indexOf(" ") === -1){
    
             console.log("no space");
    
    }
    • 控制台基本操作
    • alert("hello, welcome to my world!!!")   //在网页面出现弹框
      
      prompt("please introduce yourself~")   //在网页出现输入框,用户可以输入
      "Peiyu Li"
      
      let userInput = prompt("name")
      
      userInput
      "Peiyu"
      
      parseInt("78")     //字符转换成数字
      78
      
      parseInt("78dhkshdk")。 //字符转换成数字,自动滤去非数字部分
      78
      
      console.log("Good morning!!!")。  //输出,相当于print
      Good morning!!!
  • 相关阅读:
    python 监听文件夹下的文件,将文本内容写入kafka,支持断电续传 (docker 发布)
    python监控目录和文件变化
    Python 单例
    Python 面向对象 继承
    Python 面向对象 多态
    Python 面向对象 类属性和类方法
    Python 基础2
    Python 面向对象
    【bird-front】全自动数据表格组件bird-grid
    【bird-java】bird-java系列文章汇总
  • 原文地址:https://www.cnblogs.com/LilyLiya/p/14249686.html
Copyright © 2011-2022 走看看