GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Use typeof without round brackets · HowProgrammingWorks/Errors@c768877

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • JavaScript
    • 1-sync-try.js
    • 2-sync-tuple.js
    • 3-async.js
    • 4-uncaught.js
    • 5-promise.js
    • 6-async-await.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎JavaScript/1-sync-try.js‎

Copy file name to clipboard
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const sum = (a, b) => {
4-
if (typeof(a) === 'number' && typeof(b) === 'number') {
4+
if (typeof a === 'number' && typeof b === 'number') {
55
return a + b;
66
} else {
77
throw new Error('a and b should be numbers');
@@ -10,12 +10,12 @@ const sum = (a, b) => {
1010

1111
try {
1212
console.log(sum(2, 3));
13-
} catch (e) {
14-
console.log(e.message);
13+
} catch (err) {
14+
console.log(err.message);
1515
}
1616

1717
try {
1818
console.log(sum(7, 'A'));
19-
} catch (e) {
20-
console.log(e.message);
19+
} catch (err) {
20+
console.log(err.message);
2121
}
Collapse file

‎JavaScript/2-sync-tuple.js‎

Copy file name to clipboardExpand all lines: JavaScript/2-sync-tuple.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const sum = (a, b) => {
4-
if (typeof(a) === 'number' && typeof(b) === 'number') {
4+
if (typeof a === 'number' && typeof b === 'number') {
55
return [null, a + b];
66
} else {
77
return [new Error('a and b should be numbers')];
Collapse file

‎JavaScript/3-async.js‎

Copy file name to clipboardExpand all lines: JavaScript/3-async.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const sum = (a, b, callback) => {
4-
if (typeof(a) === 'number' && typeof(b) === 'number') {
4+
if (typeof a === 'number' && typeof b === 'number') {
55
callback(null, a + b);
66
} else {
77
callback(new Error('a and b should be numbers'));
Collapse file

‎JavaScript/4-uncaught.js‎

Copy file name to clipboardExpand all lines: JavaScript/4-uncaught.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ process.on('uncaughtException', err => {
55
});
66

77
const sum = (a, b) => {
8-
if (typeof(a) === 'number' && typeof(b) === 'number') {
8+
if (typeof a === 'number' && typeof b === 'number') {
99
return a + b;
1010
} else {
1111
throw new Error('a and b should be numbers');
Collapse file

‎JavaScript/5-promise.js‎

Copy file name to clipboardExpand all lines: JavaScript/5-promise.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const sum = (a, b) => new Promise((resolve, reject) => {
4-
if (typeof(a) === 'number' && typeof(b) === 'number') {
4+
if (typeof a === 'number' && typeof b === 'number') {
55
resolve(a + b);
66
} else {
77
reject(new Error('a and b should be numbers'));
Collapse file

‎JavaScript/6-async-await.js‎

Copy file name to clipboardExpand all lines: JavaScript/6-async-await.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
const sum = async (a, b) => {
4-
if (typeof(a) === 'number' && typeof(b) === 'number') {
4+
if (typeof a === 'number' && typeof b === 'number') {
55
return a + b;
66
} else {
77
throw new Error('a and b should be numbers');
@@ -18,8 +18,8 @@ const sum = async (a, b) => {
1818

1919
try {
2020
console.log(await sum(7, 'A'));
21-
} catch (e) {
22-
console.log(e.message);
21+
} catch (err) {
22+
console.log(err.message);
2323
}
2424

2525
})();

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.