-
Notifications
You must be signed in to change notification settings - Fork 30.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
doc: explain edge case when assigning port to url #19645
Changes from 2 commits
d719151
2cc61c1
257eae0
e402ff4
64863ee
aedadce
a55b432
0d39ca6
92919bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -313,10 +313,21 @@ myURL.port = 1234.5678; | |
console.log(myURL.port); | ||
// Prints 1234 | ||
|
||
// Out-of-range numbers are ignored | ||
// Numbers which are represented in scientific notation in a String, | ||
// or as very large / small numbers in a Number, | ||
// will be assigned the first digit of the coefficient, | ||
// assuming the number is normalized (for example, 0.9e30 => 9e29). | ||
|
||
myURL.port = 4.567e21; | ||
console.log(myURL.port); | ||
// Prints 4 (because the coefficient is 4.567) | ||
|
||
// Out-of-range numbers, which are not represented in scientific noation, | ||
// will be ignored. | ||
myURL.port = 1e10; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it isn't super clear that It got me thinking that it might be good to just describe the actual algorithm for assigning a number to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've rephrased the whole thing, adopting most of your advice, and it is much clearer now in my opinion. |
||
console.log(myURL.port); | ||
// Prints 1234 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: this empty line seems redundant. |
||
``` | ||
|
||
The port value may be set as either a number or as a String containing a number | ||
|
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.
Nit: noation -> notation