【JavaScript基础系列】决定你的人生能走多远的,是基础。
发布日期:2021-05-09 09:33:26 浏览次数:8 分类:博客文章

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

������

���������javaScript���������������������������������������dom���������bom���������������������������������js���������������������������������������������������������������������javaScript��������������������������������������������������������������������������������������������������������� ������������javaScript���������������������������������������������������������������������������javaScript������������������������������������������������������������������������������������������������������������

��������� ������������

������ ���������������������������������

���������������(String)  ������������������������������������������������������������������js���������������������string��� ��������������� "string"������������������������js���������������������������������������������������js���������������������������������������������������������������������������Number���boolean���null���undefined������������������������������������������������������������������������

������������js������������������������������

���������������������������������������

��������������� ������������������������������������������

������������ 1 var str = "���������������������"; 

���������������������������������str ������������������������������������ ��������� 

���������������������js���������String���������������

1 /*****************************2                 ���������������������������������������3                 ���������������������������������������4                 ���chorme������������������������������������5 */6                 var str = new String("hello world"); 7                 console.log(str);

������������������������������������������������������������������������������������������������������������

������������������������������������������������������js���������String������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������String���������

������������������������String���������������chorme���������������������������������������

������

���������������������������������

������

������������������������������typeof������������������������������

/*****************************                ���������������������������������������                ���������������������������������������                ���chorme������������������������������������            */                var str = new String("hello world");                 console.log(str);������//������1            /*****************************                ������typeof������������������������������������object            */                var _type = typeof str;                console.log(_type)������//object            /*****************************                ������������������������������������������                ���������������������������                typeOf������string            */                var str1 = "hello world";                console.log(str1); //������2                var _type1 = typeof str1;                console.log(_type1)������//string

 

���������������������������������������,

console.log(str === str1); //false

���������������������������������������new������������������������������new String()���������������������������������������������������������������������

���������������������������������������������������������������==���������str==str1���������������true���������������js���������������������������������������������������������������������������valueOf������������������������������������������

/***************************                ���������������str���valueOf���������������������������������            */            console.log("before ",str == str1);//true            str.__proto__.valueOf = function(){                return "javaScript!";            }            console.log("after ",str == str1);//false ���������������������console.log(str+str1) //javaScript!hello world

������������str���������������������valueOf��������������������������������������������� "javaScript!"���������������str1���==���������������������������false���

���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������js���������������������������������������valueOf������������������������������������������valueOf���������

js���������������������������������������������������������������������������������js���������������������������������������������������������������������������������������������������������������

������������__proto__���������������������
//������������__proto__���������������������                                console.log(str1.__proto__ === str.__proto__); //true ���������������������������������

���������������������������������������������������typeof���������������������������������������������������������������������������������js���������������new String���������������������������������������������������������������������������

������������������������������������������������������������������������������������������������������������������

������������������������

������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������chorme������������������������������������

 

������������������������11������������0���10������������������������������������������������������������������0-10������������

/*****************************                 ���������������������������������������                 ���������������������������������������������������������������                 ������������javascript������������������������������������������������������������������������                 ������������������������������������������String������������������������            */                console.log(str[0]); //h                console.log(str1[0]); //h

��������������� ������for���������������������������������������������������������������������������������������������������

Array.prototype.slice.call(str)//["h", "e", "l", "l", "o", " ", "w", "o", "r", "l", "d"]

������������������������������������������������str[11] = "!"������������������������������������������������11������������������������������������������������������

str[11] = "!";console.log(str.valueOf()) // hello world  ���������������

���������js��������������������������������������������������������������������������������������������������������������������������������������� [[PrimitiveValue]].���

��������������������������������������������������������������������������������������������������������������������������� [[PrimitiveValue]]���

 

������������

���������������������������������������������������������������������������������������������������������������������������������������������������������������������

���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

������������

������==============================================================================================

���������������

���������������������������

������������������

������������������

���������������

���������������������������������������

������������������������������������

���������������������������������

������������������������������

������================================================================================================

������������������������������ 9���12������������������

 

������

������

 

上一篇:斩荆披棘,我们走的关于程序的路
下一篇:《高性能javascript》 领悟随笔之-------DOM编程篇(二)

发表评论

最新留言

关注你微信了!
[***.104.42.241]2025年04月21日 11时47分52秒