很好的例子。。

摘自web IDL规范3.2.4.2节 stringfiers

 

In the ECMAScript binding, using a Student object in a context where a string is expected will result in the value of the object’s “name” property being used:

ECMAScript
var s = new Student();
s.id = 12345678;
s.name = '周杰倫';

var greeting = 'Hello, ' + s + '!';  // Now greeting == 'Hello, 周杰倫!'.
posted @ 2012-06-19 09:56  mosakashaka  阅读(64)  评论(0编辑  收藏  举报