Do you want BuboFlash to help you learning these things? Or do you want to add or correct something? Click here to log in or create user.



Tags
#javascript #object #string #syntax
Question

String primitives and String objects also give different results when using [...] Primitives passed to eval are treated as source code; String objects are treated as all other objects are, by returning the object. For example:

 var s1 = '2 + 2' ; // creates a string primitive var s2 = new String ( '2 + 2' ) ; // creates a String object console . log ( eval ( s1 ) ) ; // returns the number 4 console . log ( eval ( s2 ) ) ; // returns the string "2 + 2" 
Answer

Tags
#javascript #object #string #syntax
Question

String primitives and String objects also give different results when using [...] Primitives passed to eval are treated as source code; String objects are treated as all other objects are, by returning the object. For example:

 var s1 = '2 + 2' ; // creates a string primitive var s2 = new String ( '2 + 2' ) ; // creates a String object console . log ( eval ( s1 ) ) ; // returns the number 4 console . log ( eval ( s2 ) ) ; // returns the string "2 + 2" 
Answer
?

Tags
#javascript #object #string #syntax
Question

String primitives and String objects also give different results when using [...] Primitives passed to eval are treated as source code; String objects are treated as all other objects are, by returning the object. For example:

 var s1 = '2 + 2' ; // creates a string primitive var s2 = new String ( '2 + 2' ) ; // creates a String object console . log ( eval ( s1 ) ) ; // returns the number 4 console . log ( eval ( s2 ) ) ; // returns the string "2 + 2" 
Answer
If you want to change selection, open original toplevel document below and click on "Move attachment"

Parent (intermediate) annotation

Open it
String primitives and String objects also give different results when using eval() . Primitives passed to eval are treated as source code; String objects are treated as all other objects are, by returning the object. For example: var s1 = '2 + 2' ; // creates a s

Original toplevel document

String - JavaScript | MDN
the string primitive and call the method or perform the property lookup. var s_prim = 'foo'; var s_obj = new String(s_prim); console.log(typeof s_prim); // Logs "string" console.log(typeof s_obj); // Logs "object" <span>String primitives and String objects also give different results when using eval() . Primitives passed to eval are treated as source code; String objects are treated as all other objects are, by returning the object. For example: var s1 = '2 + 2'; // creates a string primitive var s2 = new String('2 + 2'); // creates a String object console.log(eval(s1)); // returns the number 4 console.log(eval(s2)); // returns the string "2 + 2" For these reasons, code may break when it encounters String objects when it expects a primitive string instead, although generally authors need not worry about the distinction.

Summary

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Details

No repetitions


Discussion

Do you want to join discussion? Click here to log in or create user.