You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why are `boolean`, `number` and `string` exempt from starting with a capital letter? Let's take `string` as an example. In Javascript, everything is an object. The string Object has prototypes for string functions such as `.toUpperCase()`.
1107
+
Why are `boolean`, `number` and `string` exempt from starting with a capital letter? Let's take `string` as an example. In Javascript, everything is an object. The string Object has prototypes for string functions such as `.toUpperCase()`.
1108
1108
1109
-
Fortunately we don't have to write `new String()` everywhere in our code. Javascript will automatically wrap string primitives into string Objects when we're applying a string function to a string primitive. This way the memory footprint is a tiny little bit smaller, and the [GC](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)) has less work to do.
1109
+
Fortunately we don't have to write `new String()` everywhere in our code. Javascript will automatically wrap string primitives into string Objects when we're applying a string function to a string primitive. This way the memory footprint is a tiny little bit smaller, and the [GC](https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)) has less work to do.
1110
1110
1111
1111
So in a sense, there two types of strings in Javascript; `{string}` literals, also called primitives and `{String}` Objects. We use the primitives because it's easier to write and uses less memory. `{String}` and `{string}` are technically both valid, but they are not the same.
1112
1112
@@ -1208,6 +1208,30 @@ function quux (foo, bar, baz) {
1208
1208
*/
1209
1209
functionquux (foo, bar, baz) {
1210
1210
1211
+
}
1212
+
1213
+
/**
1214
+
* @param{typeof bar}foo
1215
+
*/
1216
+
functionqux(foo) {
1217
+
}
1218
+
1219
+
/**
1220
+
* @param{import('./foo').bar.baz}foo
1221
+
*/
1222
+
functionqux(foo) {
1223
+
}
1224
+
1225
+
/**
1226
+
* @param{(x: number, y: string) => string}foo
1227
+
*/
1228
+
functionqux(foo) {
1229
+
}
1230
+
1231
+
/**
1232
+
* @param{() => string}foo
1233
+
*/
1234
+
functionqux(foo) {
1211
1235
}
1212
1236
````
1213
1237
@@ -2457,6 +2481,16 @@ function quux (foo) {
2457
2481
*/
2458
2482
constquux= () => {}
2459
2483
// Message: Present JSDoc @returns declaration but not available return expression in function.
2484
+
2485
+
/**
2486
+
* @returns{undefined} Foo.
2487
+
* @returns{String} Foo.
2488
+
*/
2489
+
functionquux () {
2490
+
2491
+
return foo;
2492
+
}
2493
+
// Message: Found more than one @returns declaration.
2460
2494
````
2461
2495
2462
2496
The following patterns are not considered problems:
@@ -2497,15 +2531,23 @@ function quux () {
2497
2531
*/
2498
2532
constquux= () => foo;
2499
2533
2500
-
/**
2534
+
/**
2501
2535
* @returns{Promise<void>}
2502
2536
*/
2503
2537
asyncfunctionquux() {}
2504
2538
2505
-
/**
2539
+
/**
2506
2540
* @returns{Promise<void>}
2507
2541
*/
2508
2542
async () => {}
2543
+
2544
+
/**
2545
+
* @returns Foo.
2546
+
* @abstract
2547
+
*/
2548
+
functionquux () {
2549
+
thrownewError('must be implemented by subclass!');
0 commit comments