# 语言基础
- 数据类型
```
<pre class="calibre14">```
undefined<span class="token2">,</span><span class="token5">null</span><span class="token2">,</span>boolean<span class="token2">,</span>number<span class="token2">,</span>string<span class="token2">,</span>Array基本数据类型
Object复杂数据类型
```
```
- 类型转换
```
<pre class="calibre14">```
<span class="token1">parseInt</span><span class="token2">(</span><span class="token4">"666"</span> <span class="token2">)</span> 非数字返回NaN
<span class="token1">parseFloat</span><span class="token2">(</span><span class="token4">"2.45"</span><span class="token2">)</span><span class="token2">;</span>
<span class="token2">(</span><span class="token3">1</span><span class="token2">)</span><span class="token2">.</span><span class="token1">toString</span><span class="token2">(</span><span class="token2">)</span><span class="token2">;</span>
<span class="token2">(</span><span class="token3">10</span><span class="token2">)</span><span class="token2">.</span><span class="token1">toString</span><span class="token2">(</span><span class="token3">2</span><span class="token2">)</span><span class="token2">;</span><span class="token6">//二进制</span>
<span class="token1">String</span><span class="token2">(</span>undefined<span class="token2">)</span><span class="token2">;</span> <span class="token5">null</span>也会输出字符串
<span class="token">!</span><span class="token">!</span><span class="token4">"3.5"</span> <span class="token3">true</span>
typeof <span class="token5">null</span><span class="token2">;</span> object
```
```
- 字符串
```
<pre class="calibre14">```
<span class="token4">"123我爱你"</span><span class="token2">.</span><span class="token1">charAt</span><span class="token2">(</span><span class="token3">3</span><span class="token2">)</span> 返回我<span class="token2">,</span><span class="token3">3</span>是位置
<span class="token4">"123我爱你"</span><span class="token2">.</span><span class="token1">indexOf</span><span class="token2">(</span><span class="token4">"我"</span><span class="token2">)</span> 返回<span class="token3">3</span> 找不到<span class="token">-</span><span class="token3">1</span>
<span class="token4">"123我爱你"</span><span class="token2">.</span><span class="token1">match</span><span class="token2">(</span><span class="token">/</span>爱<span class="token2">(</span><span class="token2">.</span><span class="token">*</span><span class="token2">)</span><span class="token">/</span><span class="token2">)</span> 返回数组 <span class="token2">[</span><span class="token4">"爱你"</span><span class="token2">,</span> <span class="token4">"你"</span><span class="token2">]</span> 没有找到返回 <span class="token5">null</span>
<span class="token4">"我爱你中国美国英国"</span><span class="token2">.</span><span class="token1">substring</span><span class="token2">(</span><span class="token3">1</span><span class="token2">,</span><span class="token3">4</span><span class="token2">)</span><span class="token2">;</span> 返回爱你中<span class="token2">,</span>从第<span class="token3">1</span>到<span class="token3">4</span>不包括<span class="token3">4</span>
<span class="token4">"我爱你中国美国英国"</span><span class="token2">.</span><span class="token1">substr</span><span class="token2">(</span><span class="token3">3</span><span class="token2">,</span><span class="token3">5</span><span class="token2">)</span> 第三个开始截取<span class="token3">5</span>个字符
<span class="token4">"我爱你中国人"</span><span class="token2">.</span><span class="token1">replace</span><span class="token2">(</span><span class="token">/</span>中国<span class="token">/</span><span class="token2">,</span><span class="token4">"美国"</span><span class="token2">)</span><span class="token2">;</span>
<span class="token4">"我爱你中国人"</span><span class="token2">.</span><span class="token1">search</span><span class="token2">(</span><span class="token">/</span>中国<span class="token">/</span><span class="token2">)</span><span class="token2">;</span> 找到返回下标 没找到返回<span class="token">-</span><span class="token3">1</span>
<span class="token4">"123我爱你"</span><span class="token2">.</span><span class="token1">split</span><span class="token2">(</span><span class="token4">""</span><span class="token2">)</span><span class="token2">;</span> 返回数组 支持正则
<span class="token4">"aA"</span><span class="token2">.</span><span class="token1">toLowerCase</span><span class="token2">(</span><span class="token2">)</span><span class="token2">;</span>转小写 toUpperCase大写
var string <span class="token">=</span> <span class="token2">(</span><span class="token3">2</span><span class="token2">)</span><span class="token2">.</span><span class="token1">toString</span><span class="token2">(</span><span class="token2">)</span><span class="token2">;</span>
var string <span class="token">=</span> <span class="token3">2</span><span class="token">+</span><span class="token4">''</span><span class="token2">;</span>
```
```
- 数组
```
<pre class="calibre14">```
var arr <span class="token">=</span><span class="token1">Array</span><span class="token2">(</span><span class="token3">1</span><span class="token2">,</span><span class="token3">2</span><span class="token2">,</span><span class="token3">3</span><span class="token2">)</span><span class="token2">;</span>
var arr <span class="token">=</span><span class="token2">[</span><span class="token3">1</span><span class="token2">,</span><span class="token3">2</span><span class="token2">,</span><span class="token3">3</span><span class="token2">]</span><span class="token2">;</span>
var arr <span class="token">=</span><span class="token2">{</span><span class="token4">"31536000"</span><span class="token2">:</span><span class="token4">"年"</span><span class="token2">,</span><span class="token4">"2592000"</span><span class="token2">:</span><span class="token4">"个月"</span><span class="token2">,</span><span class="token4">"604800"</span><span class="token2">:</span><span class="token4">"星期"</span><span class="token2">,</span><span class="token4">"86400"</span><span class="token2">:</span><span class="token4">"天"</span><span class="token2">,</span><span class="token4">"3600"</span><span class="token2">:</span><span class="token4">"小时"</span><span class="token2">,</span><span class="token4">"60"</span><span class="token2">:</span><span class="token4">"分钟"</span><span class="token2">,</span><span class="token4">"1"</span><span class="token2">:</span><span class="token4">"秒"</span><span class="token2">}</span><span class="token2">;</span>
<span class="token2">[</span><span class="token3">1</span><span class="token2">,</span><span class="token3">2</span><span class="token2">,</span><span class="token3">3</span><span class="token2">]</span><span class="token2">.</span><span class="token1">join</span><span class="token2">(</span><span class="token4">','</span><span class="token2">)</span><span class="token6">//数组转换字符串</span>
<span class="token4">'1,2,3'</span><span class="token2">.</span><span class="token1">split</span><span class="token2">(</span><span class="token4">','</span><span class="token2">)</span><span class="token6">//字符串转换数组</span>
$<span class="token2">.</span><span class="token1">isArray</span><span class="token2">(</span><span class="token2">[</span><span class="token2">]</span><span class="token2">)</span><span class="token2">;</span><span class="token6">// 是否数组 返回true</span>
arr<span class="token2">.</span><span class="token1">push</span><span class="token2">(</span><span class="token4">"white"</span><span class="token2">,</span><span class="token4">"test"</span><span class="token2">)</span><span class="token2">;</span><span class="token6">//尾部插入数组值 返回长度</span>
arr<span class="token2">.</span><span class="token1">unshift</span><span class="token2">(</span><span class="token4">"first"</span><span class="token2">)</span><span class="token2">;</span> <span class="token6">//头部插入</span>
arr<span class="token2">.</span><span class="token1">pop</span><span class="token2">(</span><span class="token2">)</span><span class="token2">;</span><span class="token6">//尾部删除 返回被删除元素</span>
arr<span class="token2">.</span><span class="token1">shift</span><span class="token2">(</span><span class="token2">)</span><span class="token2">;</span><span class="token6">//头部删除</span>
arr<span class="token2">.</span><span class="token1">reverse</span><span class="token2">(</span><span class="token2">)</span><span class="token2">;</span><span class="token6">//颠倒数组</span>
arr<span class="token2">.</span><span class="token1">sort</span><span class="token2">(</span><span class="token5">function</span><span class="token2">(</span>num1<span class="token2">,</span> num2<span class="token2">)</span> <span class="token2">{</span> <span class="token5">return</span> num1 <span class="token">></span> num2<span class="token2">;</span><span class="token2">}</span><span class="token2">)</span><span class="token2">;</span><span class="token6">//排序 返回排序后</span>
arr<span class="token2">.</span><span class="token1">concat</span><span class="token2">(</span><span class="token2">[</span><span class="token4">"ccc"</span><span class="token2">,</span><span class="token4">"bbbb"</span><span class="token2">]</span><span class="token2">,</span><span class="token4">'3333'</span><span class="token2">,</span><span class="token2">[</span><span class="token4">'vvccxx'</span><span class="token2">,</span><span class="token2">[</span><span class="token4">'oolll'</span><span class="token2">,</span><span class="token4">'lll'</span><span class="token2">]</span><span class="token2">]</span><span class="token2">)</span><span class="token2">;</span><span class="token6">//合并数组 返回新数据</span>
arr<span class="token2">.</span><span class="token1">slice</span><span class="token2">(</span><span class="token3">1</span><span class="token2">,</span><span class="token3">3</span><span class="token2">)</span><span class="token2">;</span> <span class="token6">//复制数组 从第一个开始第三个结束 返回新数组</span>
arr<span class="token2">.</span><span class="token1">splice</span><span class="token2">(</span><span class="token3">0</span><span class="token2">,</span><span class="token3">2</span><span class="token2">)</span><span class="token2">;</span><span class="token6">//删除前两个</span>
arr<span class="token2">.</span><span class="token1">splice</span><span class="token2">(</span><span class="token3">1</span><span class="token2">,</span><span class="token3">1</span><span class="token2">,</span><span class="token3">100</span><span class="token2">,</span><span class="token3">200</span><span class="token2">)</span><span class="token2">;</span><span class="token6">//从第二个删除1个 并添加2个新元素</span>
var max <span class="token">=</span> Math<span class="token2">.</span>max<span class="token2">.</span><span class="token1">apply</span><span class="token2">(</span>Math<span class="token2">,</span> arr<span class="token2">)</span> <span class="token6">//3</span>
var min <span class="token">=</span> Math<span class="token2">.</span>min<span class="token2">.</span><span class="token1">apply</span><span class="token2">(</span>Math<span class="token2">,</span>arr<span class="token2">)</span> <span class="token6">//1</span>
arr<span class="token2">.</span><span class="token1">indexOf</span><span class="token2">(</span>str<span class="token2">)</span><span class="token2">;</span><span class="token6">//查找元素位置 字符操作</span>
var arr<span class="token">=</span><span class="token2">[</span><span class="token4">"中国"</span><span class="token2">,</span><span class="token4">"美国"</span><span class="token2">,</span><span class="token4">"日本"</span><span class="token2">,</span><span class="token4">"韩国"</span><span class="token2">]</span><span class="token2">;</span>
arr<span class="token2">.</span><span class="token1">forEach</span><span class="token2">(</span><span class="token5">function</span><span class="token2">(</span>v<span class="token2">,</span>k<span class="token2">)</span><span class="token2">{</span>
<span class="token1">log</span><span class="token2">(</span>k<span class="token2">)</span>无返回值
<span class="token2">}</span><span class="token2">)</span>
arr<span class="token2">.</span><span class="token1">map</span><span class="token2">(</span><span class="token5">function</span><span class="token2">(</span>value<span class="token2">,</span>index<span class="token2">,</span>array<span class="token2">)</span><span class="token2">{</span>
<span class="token5">return</span> XXX
<span class="token2">}</span><span class="token2">)</span>
```
```
- json与对象
```
<pre class="calibre14">```
var str <span class="token">=</span> <span class="token4">'{"a":"2a","b":true,"c":34,"d":[1,2,"a"]}'</span><span class="token2">;</span><span class="token6">//json操作</span>
JSON<span class="token2">.</span><span class="token1">parse</span><span class="token2">(</span>str<span class="token2">)</span><span class="token2">;</span><span class="token6">//json字符串转换成对象</span>
var obj <span class="token">=</span> <span class="token1">eval</span><span class="token2">(</span><span class="token4">'('</span> <span class="token">+</span> str <span class="token">+</span> <span class="token4">')'</span><span class="token2">)</span><span class="token2">;</span><span class="token6">//3种方法</span>
var k1 <span class="token">=</span> <span class="token2">{</span>a<span class="token2">:</span><span class="token3">1</span><span class="token2">,</span>b<span class="token2">:</span><span class="token2">[</span><span class="token3">1</span><span class="token2">,</span><span class="token3">2</span><span class="token2">]</span><span class="token2">}</span><span class="token2">;</span><span class="token6">//对象</span>
var k2 <span class="token">=</span> <span class="token2">{</span><span class="token4">"k1"</span><span class="token2">:</span><span class="token3">1</span><span class="token2">,</span><span class="token4">"k2"</span><span class="token2">:</span><span class="token4">"中国"</span><span class="token2">}</span><span class="token2">;</span><span class="token6">//json标准格式 或者是关联数组</span>
JSON<span class="token2">.</span><span class="token1">stringify</span><span class="token2">(</span>k1<span class="token2">)</span> <span class="token6">//json对象转换成字符串</span>
```
```
- 时间戳13位长
```
<pre class="calibre16">```
<span class="token">+</span><span class="token5">new</span> <span class="token1">Date</span><span class="token2">(</span><span class="token2">)</span> 当前时间戳
<span class="token">+</span><span class="token5">new</span> <span class="token1">Date</span><span class="token2">(</span><span class="token4">'2014/12/24 02:08:01'</span><span class="token2">)</span><span class="token2">;</span> 转换时间戳
Date<span class="token2">.</span><span class="token1">now</span><span class="token2">(</span><span class="token2">)</span> 当前时间戳
<span class="token5">new</span> <span class="token1">Date</span><span class="token2">(</span>Date<span class="token2">.</span><span class="token1">parse</span><span class="token2">(</span><span class="token4">"2012-12-15 09:41:30"</span><span class="token2">.</span><span class="token1">replace</span><span class="token2">(</span><span class="token">/</span><span class="token">-</span><span class="token">/</span>g<span class="token2">,</span><span class="token4">"/"</span><span class="token2">)</span><span class="token2">)</span><span class="token2">)</span><span class="token2">;</span> Date对象
<span class="token5">new</span> <span class="token1">Date</span><span class="token2">(</span><span class="token3">1419184274000</span><span class="token2">)</span> Date对象
```
```
- 简介
- 第一章 数据库
- Mysql/mariadb
- 函数
- 基础
- 增删改索引
- 标准查询
- 高级查询
- TIDB集群mysql解决方案
- Redis
- 语言基础
- 5种数据类型
- 其他类型
- Sqlite
- 语言基础
- 常用查询
- 第二章 PHP
- 语言基础
- 第一课 流程控制和运算
- 第二课 数组
- 第三课 日期时间
- 第四课 常用函数
- 第五课 字符串
- 第六课 文件操作
- 第七课 面向对象
- 第八课 正则表达式
- 第九课 图片处理生成
- 第十课 curl/memche
- 第十一课 mysql和pdo
- 第十三课 cookie和session
- 第十四课 xml操作
- 第十五课 php5.3+新特性
- 第十六课 php7+
- 第十七课 密码安全
- 废弃函数
- php命令行
- redis应用
- 算法
- 排序算法
- 基础算法
- 无限级分类
- 自定义函数Fn
- 查找算法
- 自定义函数数据函数fn
- laravel
- 路由
- 常用语句
- 数据库
- dingo/api
- Yii2
- 控制器
- 常用类
- 数据库
- redis
- thinkphp6
- TP6文档
- TP6插件
- dedecms
- 织梦标签大全
- 数据库操作
- 内置函数和定义函数
- 织梦核心改动
- 织梦插件/底层标签开发
- PHP相关工具
- composer
- php开发环境phpenv
- Phpstorm使用
- windows编译php扩展
- PHP开源库
- 开源项目管理禅道
- sns_auth
- php-casbin权限控制
- php-jwt
- 微信SDKeasywechat
- querylist采集库
- workerman
- Box/Spout处理excel和csv
- dll扩展
- redis/memche/xdebug
- redis
- Lua
- php_xlswriter
- event
- swoole
- 常用代码库
- 微擎框架
- 第一课全局变量
- 第二课常用函数
- 第三课自定义微擎独有函数
- 第四课数据库操作
- 第五课微信端回复
- 第六课微擎高级操作
- 第八课global函数列表
- mainfest.xml详解
- js方法
- 人人商城
- 第一课model解读
- 第二课常用语句解读
- 第三课常用js解读
- 第四课附录常见问题
- 第五课附录处理报表|支付
- 常用JSON状态码
- 第三章 JavaScript
- js基础
- 浏览器对象
- 语言基础
- html5接口
- ES6新语法
- vue
- 基础语法
- 京东vueUI组件
- uniapp
- 组件开发规范
- nodejs
- 基础知识
- 安装node
- nvm不同版本node切换
- js常用标准库
- zepto/jquery
- weui
- js图标库
- elementUI
- validator表单验证
- layer弹出层
- requirejs
- wow动画
- 动画animate
- swiper4
- 百度编辑器
- flyio/axios/qs
- jquery.form
- bootstrap3
- clipboard复制
- slideout侧滑
- imagehover.css图片悬停动画
- webpack打包
- Bulma UI框架
- store 客户端存储
- lottie动画创建库
- sweetalert
- js自定义函数
- 常见JSSDK
- 微信公众号JSSDK
- 腾讯地图jssdk
- 微信小程序
- 第四章 编程语言
- markdown语言
- Dart语言
- Dart语言基础
- Flutter框架
- Lua语言
- 字符串,数组,表
- 自定义方法
- go语言
- 第1.1语言基本语法
- 第1.2流程控制
- 第1.3函数
- 第1.4结构体
- 第1.5接口
- 第1.6包
- go语言框架Gin
- CSS3语言
- CSS与CSS3
- 选择符
- 属性
- css3
- loading动画
- HTML5语言
- less
- sass
- C#
- 基础知识
- 函数
- 第五章 开发工具
- git
- nginx/apache服务器
- Linux常用操作
- crontab定时任务
- 注册表与cmd
- 阿里云ECS
- frp穿透和ssl续期
- 宝塔安装
- 树莓派
- 浏览器模拟
- 火狐/chrome常用插件
- WSL安装使用
- mac brew和终端命令
- win10相关