当前位置:网站首页>Why can basic data types call methods in JS
Why can basic data types call methods in JS
2022-07-07 13:08:00 【Dax1_】
problem
Why? string This basic data type can call methods , for example ‘a’.indexOf('a')
, Isn't method invocation the ability of an object ?
answer
- JS In order to facilitate the operation of basic data types , Provides 3 Special reference types :Boolean、Number、String, They have basic types of special behaviors
- actually , Whenever you read a basic type ,JS Internally, a basic wrapper type object is automatically created , Let's call some methods
'a'.indexOf('a')
In the calling process, you will firstlet str = new String('a')
, And then call indexOf, After calling, makestr = null
, Destroy the object .
边栏推荐
猜你喜欢
线程池拒绝策略最佳实践
Practical example of propeller easydl: automatic scratch recognition of industrial parts
How to continue after handling chain interruption / sub chain error removed from scheduling
【无标题】
About the problem of APP flash back after appium starts the app - (solved)
《ASP.NET Core 6框架揭秘》样章[200页/5章]
Coscon'22 community convening order is coming! Open the world, invite all communities to embrace open source and open a new world~
DHCP 动态主机设置协议 分析
高瓴投的澳斯康生物冲刺科创板:年营收4.5亿 丢掉与康希诺合作
2022 polymerization process test question simulation test question bank and online simulation test
随机推荐
Adopt a cow to sprint A shares: it plans to raise 1.85 billion yuan, and Xu Xiaobo holds nearly 40%
2022 practice questions and mock examination of the third batch of Guangdong Provincial Safety Officer a certificate (main person in charge)
API query interface for free mobile phone number ownership
PCAP学习笔记二:pcap4j源码笔记
Layer pop-up layer closing problem
DHCP 动态主机设置协议 分析
- Oui. Migration entièrement automatisée de la Sous - base de données des tableaux d'effets sous net
通过Keil如何查看MCU的RAM与ROM使用情况
博文推荐|Apache Pulsar 跨地域复制方案选型实践
Unity 构建错误:当前上下文中不存在名称“EditorUtility”
抓细抓实抓好安全生产各项工作 全力确保人民群众生命财产安全
regular expression
PACP学习笔记一:使用 PCAP 编程
Creation and assignment of graphic objects
初学XML
事务的七种传播行为
php——laravel缓存cache
Practical case: using MYCAT to realize read-write separation of MySQL
Smart cloud health listed: with a market value of HK $15billion, SIG Jingwei and Jingxin fund are shareholders
What kind of methods or functions can you view the laravel version of a project?