File tree Expand file tree Collapse file tree 1 file changed +101
-1
lines changed Expand file tree Collapse file tree 1 file changed +101
-1
lines changed Original file line number Diff line number Diff line change @@ -649,11 +649,111 @@ Mantenha as regras para um seletor em dispositos móveis e demais dispositos, se
649649}
650650```
651651
652-
653652### Javascript
654653
655654#### Javascript Syntax
656655
656+ Sempre use ponto e vírgula
657+
658+ ``` javascript
659+ // Good
660+ const $items = document .querySelectorAll (' .items' );
661+
662+ // Bad
663+ const $items = document .querySelectorAll (' .items' )
664+ ```
665+
666+ Use aspas simples
667+
668+ ``` javascript
669+ // Good
670+ let string = ' Default' ;
671+ const target = $element .getAttribute (' data-target' );
672+
673+ // Bad
674+ let string = " Default" ;
675+ const target = $element .getAttribute (" data-target" );
676+ ```
677+
678+ Mantenha o ` else ` na mesma linha do fechamento do ` if ` .
679+
680+ ``` javascript
681+ // Good
682+ if ( true ) {
683+ ...
684+ } else {
685+ ...
686+ }
687+
688+ // Bad
689+ if ( true ) {
690+ ...
691+ }
692+ else {
693+ ...
694+ }
695+ ```
696+
697+ Use espaço entre os operadores.
698+
699+ ``` javascript
700+ // Good
701+ for (i = 0 ; i < 10 ; i++ ) {
702+ ...
703+ }
704+
705+ // Bad
706+ for (i= 0 ;i< 10 ;i++ ) {
707+ ...
708+ }
709+ ```
710+
711+ Use espaço fora dos ` () ` , mas não dentro.
712+
713+ ``` javascript
714+ // Good
715+ if (condition) {
716+ statement
717+ }
718+
719+ // Bad
720+ if ( condition ){
721+ statement
722+ }
723+ ```
724+
725+ Sempre use ` {} ` para os blocos condicionais.
726+
727+ ``` javascript
728+ // Good
729+ if (condition) {
730+ statement
731+ } else if (condition) {
732+ statement
733+ } else {
734+ statement
735+ }
736+
737+ // Bad
738+ if (condition) statement;
739+ else if (condition) statement;
740+ else statement;
741+ ```
742+
743+ Para checar a igualdade, sempre use ` === ` ;
744+
745+ ``` javascript
746+ // Good
747+ if (foo === ' foo' ) {
748+ statement
749+ }
750+
751+ // Bad
752+ if (foo == ' foo' ) {
753+ statement
754+ }
755+ ```
756+
657757#### Javascript Comments
658758
659759#### Javascript Variables
You can’t perform that action at this time.
0 commit comments