607的彩的正确网址

现在的位置: 607的彩的正确网址 > web前端 > 正文

JavaScript中基本类型和引用类型的值是什么

2020年02月14日 web前端 ⁄ 共 2113字 ⁄ 字号 评论关闭

607的彩的正确网址  yigebianliangkeyicunfangliangzhongleixingdezhi,jibenleixingdezhi(primitive values)heyinyongleixingdezhi(reference values)。

607的彩的正确网址  es6 yinruleyizhongxindeyuanshishujuleixing symbol,biaoshiduyiwuerdezhi。tashi javascript yuyandediqizhongshujuleixing,qianliuzhongshi:undefined、null、buerzhi(boolean)、zifuchuan(string)、shuzhi(number)、duixiang(object)。

  基本类型

607的彩的正确网址  javascript zhonggongyou 6 zhongjibenshujuleixing:undefined、null、boolean、number、string、symbol (new in es 6) !

607的彩的正确网址  yueding:jibenshujuleixingyuyuanshishujuleixingdengyi。

607的彩的正确网址  jibenshujuleixingdezhishianzhifangwende。

  jibenleixingdezhishibukebiande:

  var str = "123hello321";

  str.touppercase(); // 123hello321

  console.log(str); // 123hello321

  jibenleixingdebijiaoshitamendezhidebijiao

  var a = 1;

  var b = true;

  console.log(a == b); // true

  console.log(a === b); // false

  shangmian a he b deshujuleixingbutong,danshiyekeyijinxingzhidebijiao,zheishiyinweizaibijiaozhiqian,zidongjinxingleshujuleixingde yinshizhuanhuan。

  == : zhijinxingzhidebijiao

  === : bujinjinxingzhidebijiao,haiyaojinxingshujuleixingdebijiao

  jibenleixingdebianliangshicunfangzaizhanneicun(stack)lide

  var a,b;

607的彩的正确网址  a = "zyj";

  b = a;

607的彩的正确网址  console.log(a); // zyj

607的彩的正确网址  console.log(b); // zyj

  a = "hehe"; // gaibian a dezhi,bingbuyingxiang b dezhi

  console.log(a); // hehe

607的彩的正确网址  console.log(b); // zyj

  引用类型

  chuguoshangmiande 6 zhongjibenshujuleixingwai,shengxiadejiushiyinyongleixingle,tongchengwei object leixing。xifendehua,you:object leixing、array leixing、date leixing、regexp leixing、function leixing deng。

  yinyongleixingdezhishianyinyongfangwende。

  引用类型的值是可变的

  var obj = {name:"zyj"}; // chuangjianyigeduixiang

  obj.name = "percy"; // gaibian name shuxingdezhi

  obj.age = 21; // tianjia age shuxing

607的彩的正确网址  obj.givemeall = function(){

  return this.name + " : " + this.age;

607的彩的正确网址  }; // tianjia givemeall fangfa

  obj.givemeall();

  引用类型的比较是引用的比较

  var obj1 = {}; // xinjianyigekongduixiang obj1

607的彩的正确网址  var obj2 = {}; // xinjianyigekongduixiang obj2

607的彩的正确网址  console.log(obj1 == obj2); // false

  console.log(obj1 === obj2); // false

  yinwei obj1 he obj2 fenbieyinyongdeshicunfangzaiduineicunzhongde2gebutongdeduixiang,gubianliang obj1 he obj2 dezhi(yinyongdizhi)yeshibuyiyangde!

607的彩的正确网址  yinyongleixingdezhishibaocunzaiduineicun(heap)zhongdeduixiang(object)

  与其他编程语言不同,JavaScript 不能直接操作对象的内存空间(堆内存)。

607的彩的正确网址  var a = {name:"percy"};

  var b;

  b = a;

  a.name = "zyj";

  console.log(b.name); // zyj

  b.age = 22;

607的彩的正确网址  console.log(a.age); // 22

607的彩的正确网址  var c = {

  name: "zyj",

  age: 22

  };

607的彩的正确网址  ruxia:zhanneicunzhongbaocunlebianliangbiaoshifuhezhixiangduineicunzhonggaiduixiangdezhizhen;duineicunzhongbaocunleduixiangdeneirong。

  检测类型

607的彩的正确网址  typeof:jingchangyonglaijianceyigebianliangshibushizuijibendeshujuleixing

  var a;

  typeof a; // undefined

  a = null;

  typeof a; // object

  a = true;

607的彩的正确网址  typeof a; // boolean

  a = 666;

  typeof a; // number

607的彩的正确网址  a = "hello";

607的彩的正确网址  typeof a; // string

  a = symbol();

  typeof a; // symbol

607的彩的正确网址  a = function(){}

607的彩的正确网址  typeof a; // function

  a = [];

607的彩的正确网址  typeof a; // object

  a = {};

  typeof a; // object

  a = /aaa/g;

607的彩的正确网址  typeof a; // object

607的彩的正确网址  instanceof:yonglaipanduanmougegouzaohanshude prototype shuxingsuozhixiangdeduixiangshifoucunzaiyulingwaiyigeyaojianceduixiangdeyuanxinglianshang。

607的彩的正确网址  jiandanshuojiushipanduanyigeyinyongleixingdebianliangjutishibushimouzhongleixingdeduixiang:

607的彩的正确网址  ({}) instanceof object // true

  ([]) instanceof array // true

  (/aa/g) instanceof regexp // true

  (function(){}) instanceof function // true

607的彩的正确网址  yishangjiushijavascript shenrulejiejibenleixingheyinyongleixingdezhidexiangguanjieshao,yaolejiegengduojishuzhishi,keyishangxuebuyuan。

baoqian!pinglunyiguanbi.

2元中国福利彩票怎么看 2元买彩票选几个数字 2元中国福利彩票的买法 2元就可以打1毛的斗地主棋牌 2元彩是值得您信赖的 2元斗地主群 2元的彩的网 2元彩票双色球走势图双色球 2元彩票网全国走势图 2元就可以打1毛的炸金花棋牌