Friday, April 3, 2015

window[] and eval()


Both eval and window[] is used to convert string to JavaScript variable or method but little difference is shown below.

window[] 

  1.   This is can access the global variable only
  2.   This is the window object.
  3.   If the variable is undefined, it will return undefined, but not an error.
eval()

  1.      eval() can access the global and local variable value.
  2.      This is interprets arbitrary JavaScript statement.
  3.      If the variable is undefined, you will get and error on executing time.

Unknown Software Engineer

No comments:

Post a Comment