zoukankan      html  css  js  c++  java
  • js常见知识点(1)

    对象访问

    book.topic
    等价于
    book['topic']
    var index = "topic"
    book[index]
    等价于
    book.topic

    Math函数

    Math.pow(2,3)
    Math.round(1.6)
    Math.ceil(0.6)
    Math.floor(0.6)
    Math.random()

    NaN,Infinity,-Infinity

    0/0 = NaN
    n/0 = Infinity
    -n/0 = -Infinity
    判断是否是NaN
    x != x        -->为true
    isNaN(x)      -->为true
    判断是否是NaN,Infinity,-Infinity
    isFinity(x)   -->为true

    字符串方法

    var str = 'Hello world'
    s.charAt(0)             -->'H'
    s.substring(1,4) -->'ell' s.substring(4) -->'o world' s.substring(-4) -->'Hello world' s.slice(1,4) -->'ell' s.slice(4) -->'o world' s.slice(-4) -->'orld' sustring和slice方法大体相同但是在传入负数时,slice返回后几位字符,substring返回字符串。
    s.indexOf(
    'l') -->2 s.lastIndexOf('l') -->9 s.indexOf('l',3) -->3 'l'在3及3之后首次出现的位置
    s.split(
    ',') s.replace('l','L') s.toUpperCase() s.toLowerCase()
  • 相关阅读:
    韦到头打印链表
    字符串替换
    二维数组中的查找
    字符串加解密
    简单密码破解
    vue中store模块化
    使用requests抓取网页内容
    PyQt中的一些小问题
    微信公众号之Token验证
    编译BOOST中的PYTHON模块
  • 原文地址:https://www.cnblogs.com/zhoulixue/p/6429827.html
Copyright © 2011-2022 走看看