4 ms·
none of the JavaScript ones even work in Node.js, I'd probably consider console.log('Hello, world!'); to be the closest to universal one.
by cwmma 14y ago
none of the JavaScript ones even work in Node.js, I'd probably consider
console.log('Hello, world!');
to be the closest to universal one.
- deleted 14y ago[deleted]
- beatgammit 14y agoSome implementations don't define console, so this wouldn't work in some (for example, Rhino). Something like this would be more universal: if (typeof console === 'object') { console.log('Hello, World!'); } else if (typeof document === 'object') { document.write('Hello, World!'); } else { print('Hello, World!'); } http://progopedia.com/implementation/rhino/ http://progopedia.com/implementation/rhino/
- cwmma 14y agogod damn rhinoceruses fucking everything up.