12. A system for detecting and replacing global variables in code, comprising: one or more non-transitory computer-readable storage media, and program instructions stored on at least one of the one or more storage media; and a hardware processor for executing the program instructions, the program instructions comprising: code instructions for receiving a JAVASCRIPT code having at least one of a plurality of globally defined functions, said JAVASCRIPT code is received according to a user input received via an interface and generating at least one code segment for each globally defined function in said JAVASCRIPT code; code instructions for generating at least one call flow graph for each one of said at least one of globally defined functions; code instructions for generating an inter-procedural control flow graph for each one of said call flow graph; code instructions for generating an inter-procedural dominator graph for each one of said inter-procedural control flow graph; code instructions for identifying each of referenced global variables within each of said inter-procedural dominator graph and determining a JAVASCRIPT scope of each of said referenced global variables; code instructions for identifying at least one of: one or more confined global variables which receive a value within a first JAVASCRIPT scope of each of said referenced global variables wherein said value is not referenced outside of said first JAVASCRIPT scope, and one or more repeating global variables accessed repeatedly within a second JAVASCRIPT scope of each of said referenced global variables; and code instructions for automatically adding local variables in place of said repeating global variables or said confined global variables.
12. A system for detecting and replacing global variables in code, comprising: one or more non-transitory computer-readable storage media, and program instructions stored on at least one of the one or more storage media; and a hardware processor for executing the program instructions, the program instructions comprising: code instructions for receiving a JAVASCRIPT code having at least one of a plurality of globally defined functions, said JAVASCRIPT code is received according to a user input received via an interface and generating at least one code segment for each globally defined function in said JAVASCRIPT code; code instructions for generating at least one call flow graph for each one of said at least one of globally defined functions; code instructions for generating an inter-procedural control flow graph for each one of said call flow graph; code instructions for generating an inter-procedural dominator graph for each one of said inter-procedural control flow graph; code instructions for identifying each of referenced global variables within each of said inter-procedural dominator graph and determining a JAVASCRIPT scope of each of said referenced global variables; code instructions for identifying at least one of: one or more confined global variables which receive a value within a first JAVASCRIPT scope of each of said referenced global variables wherein said value is not referenced outside of said first JAVASCRIPT scope, and one or more repeating global variables accessed repeatedly within a second JAVASCRIPT scope of each of said referenced global variables; and code instructions for automatically adding local variables in place of said repeating global variables or said confined global variables. 13. The system of claim 12 , further comprising code instructions for identifying a definition of said each referenced global variable along paths of said inter-procedural dominator path, and identifying a scope of a location of said definition, by starting from a node containing said each referenced global variable and searching along paths of said inter-procedural dominator graph in a direction towards an entry node of said inter-procedural dominator graph.