Skip to content

Instantly share code, notes, and snippets.

@The-Quill
Created February 18, 2016 12:52
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save The-Quill/2a2b119e63015a901c6f to your computer and use it in GitHub Desktop.
shtriped rheview

#Speling You mispeled SEPERATOR.


#Naming

Try and avoid single character or abbreviated names:

strToInt(s)

Versus with another 5 characters

strToInt(string)

Much more readable


#Misc

You can and should use templating strings here:

' [' + [stmt.name].concat(stmt.args).join(COMPONENTS.SEPERATOR) + ']'

In addition, you shouldn't be doing that many things on one line, you should split your logic up a little more to let your code explain what that is.

function undef(obj) {
    return typeof obj === 'undefined'
}

This won't actually work, as when you try to pass an undefined value into a function, it'll throw a ReferenceError


#Code Formatting

Try and declare your variables on one line each, and each with the var keyword, otherwise you may run into an issue where your variables become globals:

for example

var a,
    b

a and b are locals

var a
    b

a is a local, b is a global.

return i

semicolons pls.

This is my preference, but I usually try to return false instead of null, because it makes for less falsy and truthy values.

if (functionResult == null)

versus

if (functionResult)

#switch me on

Your massive switch statement can be extracted a little more if you like by assigning functions to properties in an object, and calling the function based on the stmt.name value.


#Overall

Overall, your code is good, just try to extract some of your logic out so that there's not so much in there, and try to extract as much of the duplicate code as you can into functions and multiuse stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment