Good afternoon, there is a condition in the code:

if (typeof sbjs.get.current.typ !== "undefined") { var type_traffic = sbjs.get.current.typ; } else { var type_traffic = null; } 

it is necessary to replace this condition with a more compact entry

    1 answer 1

    Use design? :

      var type_traffic = (typeof sbjs.get.current.typ !== "undefined") ? sbjs.get.current.typ : null; 

    And never declare variables inside loops / conditions. In your case, you had to declare the variable before if.

     var type_traffic; if (typeof sbjs.get.current.typ !== "undefined") { type_traffic = sbjs.get.current.typ; } else { type_traffic = null; } 
    • And never declare variables inside cycles / conditions, why? - Grundy
    • Thanks, cut the code by, a dozen other, lines of code))))) - Ivan Triumphov
    • Google
    • @ru_volt, this is only if var declared with var - Grundy
    • @ru_volt, and the rules are pretty simple - Grundy