为什么我不能在node.js中获取对象原型名称

当我运行下面的代码:

var os = require('os'); var sys= require('sys'); var ostype = os.type() + " "; sys.puts(ostype.prototype.toString()); sys.puts("\n"); 

我得到以下错误:

 node.js:116 throw e; // process.nextTick error, or 'error' event on first tick ^ TypeError: Cannot call method 'toString' of undefined at Object.<anonymous> (/home/Maria Dillon/test.js:5:27) at Module._compile (module.js:374:26) at Object..js (module.js:380:10) at Module.load (module.js:306:31) at Function._load (module.js:272:10) at Array.<anonymous> (module.js:393:10) at EventEmitter._tickCallback (node.js:108:26) 

如果我理解ECMA-262第3版的15.2.4.2,这应该工作。

PS我正在运行我build立在Cygwin上的node.js 0.5.0pre。

因为ostype是一个string ,这是一个原始值。 在这里你可以find更多关于它的信息。

祝你好运!