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!!!
  • 相关阅读:
    不断学习和思考让自己成长、过得充实快乐!
    先制订个能力提升计划
    如何删除SQL Server下注册的服务器
    [转摘] 我的同学聚会--性格决定命运
    如何提高阅读速度2
    Oracle IW,WW的区别
    想象5年后的你(很多人看了很受启迪!)
    女要富养
    5年内买车买房(理财篇)
    [转摘] 从月薪3500到身价700万 我在上海的奋斗岁月
  • 原文地址:https://www.cnblogs.com/LilyLiya/p/14249686.html
Copyright © 2011-2022 走看看