mirror of
https://github.com/benjaminion/upgrading-ethereum-book.git
synced 2026-01-09 14:38:08 -05:00
TIL about the ?? operator
This commit is contained in:
@@ -49,10 +49,8 @@ const defaultHeadings = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
||||
const defaultExclude = undefined;
|
||||
|
||||
export default function (options) {
|
||||
const headings =
|
||||
options?.headings !== undefined ? options.headings : defaultHeadings;
|
||||
const exclude =
|
||||
options?.exclude !== undefined ? options.exclude : defaultExclude;
|
||||
const headings = options?.headings ?? defaultHeadings;
|
||||
const exclude = options?.exclude ?? defaultExclude;
|
||||
return {
|
||||
name: 'myAutoLinkHeadings',
|
||||
hooks: {
|
||||
|
||||
@@ -70,7 +70,7 @@ function getChunks(tree, chunkTypes, exclude) {
|
||||
label: type.label,
|
||||
id: id,
|
||||
text: text,
|
||||
weight: type.weight === undefined ? 1 : type.weight,
|
||||
weight: type.weight ?? 1,
|
||||
});
|
||||
}
|
||||
return SKIP;
|
||||
|
||||
Reference in New Issue
Block a user