简单类型对象 String

简单值不是对象,因此也没有属性方法,因此运行下面代码时
 
var s1 = “some text”;
var s2 = s1.substring(2);
 
实际上是运行在read模式,字符串的值会被直接从内存读取,会触发如下步骤
 
- Create an instance of the String type(new String())
 
- Call the specified method on the instance
 
- Destroy the instance

因此在字符串,数字,布尔值上调用方法都会按上面步骤执行

posted on 2016-01-28 09:51  迷茫小飞侠  阅读(120)  评论(0编辑  收藏  举报

导航