vue工具函数中用到的js方法【自用】

80 阅读1分钟

通过这篇文章你可以学到什么?

vue源码,dist/vue.js 14-377行,用到的所有的js方法,学完以下方法后就可以愉快的阅读源码。

类型判断

  • typeof
  • Object.prototype.toString
  • isNaN

this指向

  • call
  • bind
  • apply

数组方法

  • Array.isArray
  • indexOf
  • splice
  • new Array
  • concat
  • reduce
  • join
  • every

对象方法

  • Object.freeze
  • Object.create
  • Object.prototype.hasOwnProperty
  • instanceof
  • Object.keys

字符串方法

  • slice
  • split
  • String
  • toLowerCase
  • toUpperCase
  • replace
  • charAt

数字方法

  • parseFloat
  • Math.floor

日期

  • getTime

数据类型转换

  • JSON.stringify
  • toString

其他

  • 正则
  • ||
  • &
  • ?:;
  • obj[a] (对象通过变量取值)
  • arguments
  • 闭包
  • 递归

源码教学地址

juejin.cn/post/702427…