Reputation: 32392
When I run the following code:
var os = require('os');
var sys= require('sys');
var ostype = os.type() + " ";
sys.puts(ostype.prototype.toString());
sys.puts("\n");
I get the following error:
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)
If I understand 15.2.4.2 of ECMA-262 3rd edition, this should work.
PS I am running node.js 0.5.0pre which I built myself on Cygwin.
Upvotes: 2
Views: 2606
Reputation: 3541
Because ostype
is an string
, which is a primitive value. Here you'll find more information about it.
Good luck!
Upvotes: 3