According to the ECMA-262 specification, the following statements return 1 :
1
eval("1;;;;;") eval("1;{}") eval("1;var a;")
Ensuring that:
The StatementList value is the value of the last value that produces the Statement in the Statement list.
Can you explain these different results?
eval("{}") // undefined eval("var a={}; a;") // {} eval("var a={};") // undefined
What is the difference between 1; and {}; ?
1;
{};
Alone {} interpreted as a block, not an object. It does not contain instructions, so it does not affect the value of, say, eval("1;{}") . To make it be interpreted as an object, you can use parentheses:
{}
eval("1;{}")
eval("1;({})"); // {}
It seems to me that eval interprets {} as code block delimiters and therefore has no inherent meaning.
eval
Source: https://habr.com/ru/post/1414783/More articles:Data structure for efficiently matching function calls - c ++jQuery unload vs beforeunload - javascriptTrying to accurately measure 3D distance from a 2D image - mathhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1414781/adding-weights-to-all-edges-of-graph-change-in-spanning-tree-and-shortest-paths&usg=ALkJrhjYkKM_7zpP_alH6hMl683JVKEK0gProcessbuilder without redirecting StdOut - javahttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1414784/android-xy-continuous-touch-drag-coordinates&usg=ALkJrhgtWu5Et2l2kuX5gOZNmgMHd687KgCreating an instance of the constructor with default arguments - c ++Facebook like button with hash - facebookLabelFor + EditorFor on the same line? - .netHow to rotate, translate and scale a control object around a specific point in WPF - rotationAll Articles