博客
关于我
深拷贝和类型检测
阅读量:744 次
发布时间:2019-03-22

本文共 744 字,大约阅读时间需要 2 分钟。

 

//  深拷贝        var user1={name:"小明",age:18, deMent:{bumen:"市场部",no:"001"}}                  var  user2=JSON.stringify(user1);         var  user3=JSON.parse(user2);         user3.age=40;         user3.deMent.no="999";         console.log(user1); //{name: "小明", age: 18, deMent:{bumen: "市场部", no: "001"}}         console.log(user3) //{name: "小明", age: 40,deMent: {bumen: "市场部", no: "999"}}         // 深拷贝的步骤 JSON.stringify(被拷贝的对象); 把对象转为一个字符串         // JSON.parse(user2);会根据字符串生成一个新的对象         // 类型检测         /*         基本数据类型检测使用typeof来检测    console.log(变量 typeof 基本类型)         引用数据类型使用instanceof来检测    console.log(函数 instanceof Function)         */         // 检测数组         var arr=[1,2,3,4,,5];         console.log(Array.isArray(arr)); //true

 

转载地址:http://cmwwk.baihongyu.com/

你可能感兴趣的文章
Netty源码—3.Reactor线程模型四
查看>>
Netty源码—4.客户端接入流程一
查看>>
Netty源码—4.客户端接入流程二
查看>>
Netty源码—5.Pipeline和Handler一
查看>>
Netty源码—5.Pipeline和Handler二
查看>>
Netty源码—6.ByteBuf原理一
查看>>
Netty源码—6.ByteBuf原理二
查看>>
Netty源码—7.ByteBuf原理三
查看>>
Netty源码—7.ByteBuf原理四
查看>>
Netty源码—8.编解码原理一
查看>>
Netty源码—8.编解码原理二
查看>>
Netty源码解读
查看>>
netty的HelloWorld演示
查看>>
Netty的Socket编程详解-搭建服务端与客户端并进行数据传输
查看>>
Netty的网络框架差点让我一夜秃头,哭了
查看>>
Netty相关
查看>>
Netty简介
查看>>
Netty线程模型理解
查看>>
netty解决tcp粘包和拆包问题
查看>>
Netty速成:基础+入门+中级+高级+源码架构+行业应用
查看>>