zoukankan      html  css  js  c++  java
  • 字符串截取

    字符串截取,substring(int beginIndex) 返回一个新的字符串,它是此字符串的一个子字符串。
    substring(int beginIndex, int endIndex) 返回一个新字符串,它是此字符串的一个子字符串。
    beginIndex - 起始索引(包括)。从0开始
    endIndex - 结束索引(不包括)。
    "unhappy".substring(2) returns "happy"
    "hamburger".substring(4, 8) returns "urge"
    ======================
    Pattern
    java.util.regex(一个用正则表达式所订制的模式来对字符串进行匹配工作的类库包)中的一个类。一个Pattern是一个正则表达式经编译后的表现模式
    ^[a-zA-Z0-9]{6,16}$表示的就是以大小写字母和数字组成的,最小6位,最大16位的字符串。

    js 中 相等(==) 和恒等( === )的区别

     

    == 在表达式两边的数据类型不一致时,会隐式转换为相同数据类型,然后对值进行比较。

    === 不会进行类型转换,在比较时除了对值进行比较以外,还比较两边的数据类型。

    另外,数值是null,"",undefined,Nan的时候,返回的也是false.有时候判断的时候没必要一个个列举出来,一行代码解决的事情,就不要写两行。

    复制代码

    console.log(Boolean(null)); //false

    console.log(Boolean("")); //false

    console.log(Boolean(undefined)); //false

    console.log(Boolean(NaN)); //false

    console.log(Boolean(1==1)); //true

    console.log(Boolean(1=="1")); //true

    console.log(Boolean(1===1)); //true

    console.log(Boolean(1==="1")); //false

  • 相关阅读:
    Octave/Matlab初步学习
    week_3
    week_2
    week_1
    清除input[type=number]的默认样式
    js,获取和设置cookie、 localStorage
    php表单提交时获取不到post数据的解决方法
    console.log 简写
    JS合并两个数组的方法
    javascript ES5、ES6的一些知识
  • 原文地址:https://www.cnblogs.com/21heshang/p/5801705.html
Copyright © 2011-2022 走看看