JS prototype constructor转载之五

本文介绍了JavaScript中构造函数的基本概念,包括当构造函数作为普通函数调用时的行为,以及Function构造函数的特点。此外,还详细解释了valueOf()和toString()方法的功能及其在不同对象类型中的实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://www.cnblogs.com/z-lib/archive/2010/08/12/1797860.html



js三刀:constructor属性,valueOf(),toSTring

15.2.1 The Object Constructor Called as a Function

 When Object is called as a function rather than as a constructor, it performs a type conversion. 

15.3.3   Properties of the Function Constructor 

The Function constructor is itself a Function  object and its [[Class]] is "Function". The value of the [[Prototype]] internal property of the Function constructor is the standard built-in Function prototype object (15.3.4). 

/** valueOf函数:返回指定对象的原始值。 

* 对象返回值

Array数组的元素被转换为字符串,这些字符串由逗号分隔,连接在一起。其操作与 Array.toString 和 Array.join 方法相同。

BooleanBoolean 值。

Date存储的时间是从 1970 年 1 月 1 日午夜开始计的毫秒数 UTC。

Function函数本身。

Number数字值。

Object对象本身。这是默认情况。String字符串值。 

*  */
/** toString函数:是返回对象的字符串表示 

* 对象操作

Array将 Array 的元素转换为字符串。结果字符串由逗号分隔,且连接起来。

Boolean如果 Boolean 值是 true,则返回 “true”。否则,返回 “false”。

Date返回日期的文字表示法。Error返回一个包含相关错误消息的字符串。

Function返回如下格式的字符串,其中 functionname 是被调用 toString 方法函数的名称: function functionname( ) { [native code] }Number返回数字的文字表示。

String返回 String 对象的值。

默认返回 “[object objectname]”,其中 objectname 是对象类型的名称。 

*/


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值