Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
72
rated 0 times [  78] [ 6]  / answers: 1 / hits: 20577  / 13 Years ago, tue, july 26, 2011, 12:00:00

Does something similar to Java's System.getProperty(line.separator); exist in JavaScript?



Edit: I am using the non-browser JavaScript environment Node.js


More From » node.js

 Answers
35

I had the same problem and came across this quite old question. After investing for some time I finally found os.EOL at the very end of the os documentation.



var os = require('os')
console.log(JSON.stringify(os.EOL)) // prints n on my Mac


JSON.stringify is in this case important, otherwise you would only see a blank line in the console (which makes sense because that's what it should do). In an normal use case it is not needed.


[#90998] Monday, July 25, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jadyngraysons

Total Points: 455
Total Questions: 109
Total Answers: 98

Location: Trinidad and Tobago
Member since Fri, May 8, 2020
4 Years ago
jadyngraysons questions
Thu, Apr 23, 20, 00:00, 4 Years ago
Sat, Jan 18, 20, 00:00, 4 Years ago
Tue, Dec 31, 19, 00:00, 5 Years ago
;