当前位置:网站首页>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 .
边栏推荐
- @What is the difference between resource and @autowired?
- 将数学公式在el-table里面展示出来
- COSCon'22 社区召集令来啦!Open the World,邀请所有社区一起拥抱开源,打开新世界~
- Aosikang biological sprint scientific innovation board of Hillhouse Investment: annual revenue of 450million yuan, lost cooperation with kangxinuo
- 学习突围2 - 关于高效学习的方法
- [untitled]
- Awk of three swordsmen in text processing
- Day26 IP query items
- Shortcut key of Bash
- ClickHouse(03)ClickHouse怎么安装和部署
猜你喜欢
Creation and assignment of graphic objects
基于鲲鹏原生安全,打造安全可信的计算平台
Awk of three swordsmen in text processing
高瓴投的澳斯康生物冲刺科创板:年营收4.5亿 丢掉与康希诺合作
迅为iTOP-IMX6ULL开发板Pinctrl和GPIO子系统实验-修改设备树文件
《开源圆桌派》第十一期“冰与火之歌”——如何平衡开源与安全间的天然矛盾?
Go语言学习笔记-结构体(Struct)
Lingyunguang of Dachen and Xiaomi investment is listed: the market value is 15.3 billion, and the machine is implanted into the eyes and brain
关于 appium 启动 app 后闪退的问题 - (已解决)
About the problem of APP flash back after appium starts the app - (solved)
随机推荐
国泰君安证券开户怎么开的?开户安全吗?
Grep of three swordsmen in text processing
PACP学习笔记三:PCAP方法说明
飞桨EasyDL实操范例:工业零件划痕自动识别
非分区表转换成分区表以及注意事项
Design and implementation of communication protocol
通过Keil如何查看MCU的RAM与ROM使用情况
【无标题】
Shortcut key of Bash
Test next summary
《ASP.NET Core 6框架揭秘》样章[200页/5章]
- Oui. Migration entièrement automatisée de la Sous - base de données des tableaux d'effets sous net
Initialization script
How to continue after handling chain interruption / sub chain error removed from scheduling
Sed of three swordsmen in text processing
AUTOCAD——大于180度的角度标注、CAD直径符号怎么输入?
Leetcode skimming: binary tree 20 (search in binary search tree)
Steps of building SSM framework
File operation command
博文推荐|Apache Pulsar 跨地域复制方案选型实践