@@ -376,6 +376,14 @@ <h4>
376376 < code class ="javascript "> ;</ code > instead of
377377 < code class ="javascript "> ,</ code >
378378 </ h4 >
379+ < p >
380+ Object literal properties are separated by commas (< code
381+ class ="javascript "
382+ > ,</ code
383+ > ). Semicolons (< code class ="javascript "> ;</ code > ) are not allowed.
384+ The following code uses a semicolon instead of a colon in an object
385+ literal:
386+ </ p >
379387 < div class ="code-example ">
380388 < figure >
381389 < pre > < code type ="javascript "> $('.view-content').hoverscroll({
@@ -421,6 +429,12 @@ <h4>
421429
422430 < section id ="invalid-object-literal-key ">
423431 < h4 > Invalid object literal key</ h4 >
432+ < p >
433+ Object literal property names must be simple identifiers or quoted
434+ strings. The following code example tries to create a nested object
435+ by writing a dot (< code class ="javascript "> .</ code > ) in the property
436+ name:
437+ </ p >
424438 < div class ="code-example ">
425439 < figure >
426440 < pre > < code type ="javascript "> var company = new Company({
@@ -474,6 +488,14 @@ <h4>Invalid object literal key</h4>
474488
475489 < section id ="newline-after-return ">
476490 < h4 > Newline after < code class ="javascript "> return</ code > </ h4 >
491+ < p >
492+ If < code class ="javascript "> return</ code > is immediately followed by
493+ a newline character, < code class ="javascript "> undefined</ code > is
494+ returned, and the following code is interpreted as more statements.
495+ The following code expects the
496+ < code class ="javascript "> return</ code > statement to return an object
497+ literal:
498+ </ p >
477499 < div class ="code-example ">
478500 < figure >
479501 < pre > < code type ="javascript "> var homeModelTemplate = function(){
@@ -519,6 +541,11 @@ <h4>Newline after <code class="javascript">return</code></h4>
519541
520542 < section id ="missing-parens-around-parameter ">
521543 < h4 > Missing < code class ="javascript "> ( )</ code > around parameter</ h4 >
544+ < p >
545+ If an arrow function has a single parameter, and that parameter is
546+ an object destructuring, parentheses are required around the
547+ parameter. The following code omits the parentheses:
548+ </ p >
522549 < div class ="code-example ">
523550 < figure >
524551 < pre > < code type ="javascript "> < mark class ="engine-JSC "> </ mark > colls.map(< mark class ="engine-V8 "> < mark class ="engine-SM "> {</ mark > id, ...other</ mark > } < mark class ="engine-ESL "> </ mark > < mark class ="engine-TS "> < mark class ="engine-Ba "> =</ mark > ></ mark > {
@@ -567,6 +594,11 @@ <h4>Missing <code class="javascript">( )</code> around parameter</h4>
567594
568595 < section id ="keyword-variable-name ">
569596 < h4 > Keyword variable name</ h4 >
597+ < p >
598+ With a few exceptions for legacy reasons, function parameters cannot
599+ be named a keyword. The following code tries to name a function
600+ parameter < code class ="javascript "> class</ code > , which is a keyword:
601+ </ p >
570602 < div class ="code-example ">
571603 < figure >
572604 < pre > < code type ="javascript "> < mark class ="engine-JSC "> </ mark > function Classes(< mark class ="engine-ESL engine-qljs "> </ mark > < mark class ="engine-TS engine-V8 "> < mark class ="engine-Ba engine-SM "> c</ mark > lass</ mark > < mark class ="engine-TS "> ,</ mark > < mark class ="engine-TS "> sched</ mark > < mark class ="engine-TS "> )</ mark > {
@@ -609,6 +641,12 @@ <h4>Keyword variable name</h4>
609641 < h4 >
610642 Missing < code class ="javascript "> ||</ code > between expressions
611643 </ h4 >
644+ < p >
645+ Expressions can't be next to each other without an operator in
646+ between. The following code is missing the logical or operator
647+ (< code class ="javascript "> ||</ code > ) between two expressions in the
648+ < code class ="javascript "> while</ code > loop:
649+ </ p >
612650 < div class ="code-example ">
613651 < figure >
614652 < pre
@@ -650,6 +688,12 @@ <h4>
650688 < code class ="javascript "> elseif</ code > instead of
651689 < code class ="javascript "> else if</ code >
652690 </ h4 >
691+ < p >
692+ < code class ="javascript "> elseif</ code > is a keyword in some
693+ languages, but not in JavaScript. The correct code is
694+ < code class ="javascript "> else if</ code > (two words). The following
695+ code uses < code class ="javascript "> elseif</ code > by mistake:
696+ </ p >
653697 < div class ="code-example ">
654698 < figure >
655699 < pre > < code type ="javascript "> var car;
@@ -694,6 +738,11 @@ <h4>
694738
695739 < section id ="missing-comma-between-arguments ">
696740 < h4 > Missing < code class ="javascript "> ,</ code > between arguments</ h4 >
741+ < p >
742+ Function calls have a comma (< code class ="javascript "> ,</ code
743+ > )-separated arguments. The following code forgets a comma between
744+ two parameters:
745+ </ p >
697746 < div class ="code-example ">
698747 < figure >
699748 < pre > < code type ="javascript "> $.ajax({
0 commit comments