当前位置:网站首页>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 .
边栏推荐
- DETR介绍
- 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
- [binary tree] delete points to form a forest
- Per capita Swiss number series, Swiss number 4 generation JS reverse analysis
- 2022 examination questions and online simulation examination for safety production management personnel of hazardous chemical production units
- Sequoia China completed the new phase of $9billion fund raising
- [untitled]
- Smart cloud health listed: with a market value of HK $15billion, SIG Jingwei and Jingxin fund are shareholders
- ORACLE进阶(五)SCHEMA解惑
- Cinnamon 任务栏网速
猜你喜欢
Cookie
leecode3. 无重复字符的最长子串
博文推荐|Apache Pulsar 跨地域复制方案选型实践
Practical example of propeller easydl: automatic scratch recognition of industrial parts
Isprs2021/ remote sensing image cloud detection: a geographic information driven method and a new large-scale remote sensing cloud / snow detection data set
详细介绍六种开源协议(程序员须知)
How to continue after handling chain interruption / sub chain error removed from scheduling
Leetcode skimming: binary tree 22 (minimum absolute difference of binary search tree)
Milkdown 控件图标
Sed of three swordsmen in text processing
随机推荐
DrawerLayout禁止侧滑显示
【无标题】
[binary tree] delete points to form a forest
2022-07-07 Daily: Ian Goodfellow, the inventor of Gan, officially joined deepmind
非分区表转换成分区表以及注意事项
Cookie and session comparison
PHP calls the pure IP database to return the specific address
【学习笔记】线段树选做
[learn wechat from 0] [00] Course Overview
【Presto Profile系列】Timeline使用
How to continue after handling chain interruption / sub chain error removed from scheduling
[untitled]
事务的七种传播行为
The URL modes supported by ThinkPHP include four common modes, pathinfo, rewrite and compatibility modes
Leetcode skimming: binary tree 20 (search in binary search tree)
明星企业普渡科技大裁员:曾募资超10亿 腾讯红杉是股东
.Net下极限生产力之efcore分表分库全自动化迁移CodeFirst
Leetcode skimming: binary tree 25 (the nearest common ancestor of binary search tree)
Sequoia China completed the new phase of $9billion fund raising
云检测2020:用于高分辨率遥感图像中云检测的自注意力生成对抗网络Self-Attentive Generative Adversarial Network for Cloud Detection