zoukankan      html  css  js  c++  java
  • js小tips和小笔记

    1. (+a)会自动把字符串(如果)变为Number类型
      如:var a = '1', b=1;    
           +a+1+'a' => '2a'
           +b+1+'b' => '2b'
    2. 函数内的arguments类数组对象,不能直接当数组用,如[1].concat(arguments)不会得到[1, arguments[0], arguments[1],...],而是[1, arguments],
      可以先var argArr = Array.prototype.slice.call(arguments)或这样直接调用数字方法:[].reduce.apply(arguments,function (before,currentVal) {return before+currentVal})。
    3. arr.slice(startIndex, endIndex)的结果是得到一个 [startIndex, endIndex)区间内的数组, arr本身不变,slice是个纯函数;
      arr.splice(startIndex, endIndex)的结果也是一个 [startIndex, endIndex)区间内的数组,但是arr本身会变成删除 [startIndex, endIndex)区间内的项后剩余项组成的数组;
      总结:slice和splice都可以用来获取某个区间范围内的数组,但是slice不会改变原数组,splice会改变原来的数组。
  • 相关阅读:
    c# 字符串中某个词出现的次数及索引
    c# 冒泡排序
    WCF 高级知识
    Web Api基础知识
    Web Services基础知识
    WCF Demo
    IIS部署WCF常见错误
    IIS部署WCF
    IIS部署WCF错误
    WCF基础知识
  • 原文地址:https://www.cnblogs.com/yigeqi/p/6266152.html
Copyright © 2011-2022 走看看