-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ES5/ESnext switcher on about page
- Loading branch information
Showing
2 changed files
with
97 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,9 @@ scalable network applications. In the following "hello world" example, many | |
connections can be handled concurrently. Upon each connection the callback is | ||
fired, but if there is no work to be done Node is sleeping. | ||
|
||
```javascript | ||
Modern JavaScript: | ||
|
||
```js | ||
const http = require('http'); | ||
|
||
const hostname = '127.0.0.1'; | ||
|
@@ -24,6 +26,22 @@ http.createServer((req, res) => { | |
}); | ||
``` | ||
|
||
ES5: | ||
|
||
```js | ||
var http = require('http'); | ||
|
||
var hostname = '127.0.0.1'; | ||
var port = 1337; | ||
|
||
http.createServer(function(req, res) { | ||
res.writeHead(200, { 'Content-Type': 'text/plain' }); | ||
res.end('Hello World\n'); | ||
}).listen(port, hostname, function() { | ||
This comment has been minimized.
Sorry, something went wrong.
benjamingr
Member
|
||
console.log('Server running at http://%s:%d/', hostname, port); | ||
}); | ||
``` | ||
|
||
This is in contrast to today's more common concurrency model where OS threads | ||
are employed. Thread-based networking is relatively inefficient and very | ||
difficult to use. Furthermore, users of Node are free from worries of | ||
|
1 comment
on commit 900f951
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- It might be beneficial to explain how to write these Modern/ES blocks to the docs.
- textContent doesn't work in IE8, neither does addEventListener, you can
textContent
and fallback oninnerText
on that and same for attachEvent. Do we even support IE8? If we do - this code has lots of.map
.forEach
etc - though those are probably polyfilled.
Other comments inline.
Is the !important actually needed here?