213). The Crockford’s subset does not include which function in JavaScript?
[A] eval()
[B] coeval()
[C]equal()
[D] equivalent()
Show Answer
Correct Answer: eval()
Notes:
Answer: a
Explanation: The Crockford’s subset does not include the with and continue statements or the eval() function. It defines functions using function definition expressions only and does not include the function definition statement.
214). What does javascript use instead of == and !=?
[A]It uses bitwise checking
[B]It uses === and !== instead
[C] It uses equals() and notequals() instead
[D] It uses equalto()
Show Answer
Correct Answer: It uses === and !== instead
Notes:
Answer: b
Explanation: The subset does not include the comma operator, the bitwise operators, or the ++ and — operators. It also disallows == and != because of the type conversion they perform, requiring use of === and !== instead.
215). What is being imposed on each subset to ensure that it conforms to the subset?
[A]A parser to parse the code
[B]A parser that parses and adds to the subset
[C] A static verifier that parses code
[D]A predefined function to parse the code
Show Answer
Correct Answer: A static verifier that parses code
Notes:
Answer: c
Explanation: Each subset is coupled with a static verifier that parses code to ensure that it conforms to the subset.
216). Why was “The Good Parts” designed as a language subset in JavaScript?
[A]To improve programmer flexibility
[B]To balance the workload of the programmer
[C] To create an in-built compiler and interpreter
[D]To improve programmer productivity
Show Answer
Correct Answer: To improve programmer productivity
Notes:
Answer: d
Explanation: The Good Parts is a language subset designed for aesthetic reasons and with a desire to improve programmer productivity. There is a larger class of subsets that have been designed for the purpose of safely running untrusted JavaScript in a secure container or “sandbox”.
217). Which is the subset that is a secure container designed for the purpose of safely running untrusted JavaScript?
[A]Sandbox
[B] The Good Parts
[C]Both Sandbox and Good Parts
[D]Web browser
Show Answer
Correct Answer: Sandbox
Notes:
Answer: a
Explanation: There is a larger class of subsets that have been designed for the purpose of safely running untrusted JavaScript in a secure container or “sandbox”.
218). Why is this keyword not preferred in JavaScript?
[A] Highly memory consuming
[B]Functions should access the global objects
[C]Functions should not access the global objects
[D] Very inefficient to use
Show Answer
Correct Answer: Functions should not access the global objects
Notes:
Answer: c
Explanation: The this keyword is forbidden or restricted because functions (in non-strict mode) can access the global object through this. Preventing access to the global object is one of the key purposes of any sandboxing system.
219). Which are the two functions that are not allowed in any secure subset?
[A]evaluate() and restrict()
[B]eval() and the Function() constructor
[C] debugger() and test()
[D]eval() and debugger()
Show Answer
Correct Answer: eval() and the Function() constructor
Notes:
Answer: b
Explanation: eval() and the Function() constructor are not allowed in any secure subset because they allow the execution of arbitrary strings of code, and these strings cannot be statically analyzed.
220). Which is the object that defines methods that allow complete control over page content?
[A]The client-side document object
[B]The server-side document object
[C]Both client-side and server-side document object
[D]Web document object
Show Answer
Correct Answer: The client-side document object
Notes:
Answer: a
Explanation: A web page is divided into two object documents in which one is client-side document object and the other is server-side document object. The client-side document object defines methods that allow complete control over page content
221). Which was one of the first security subsets proposed?
[A]FBJS
[B]Caja
[C]dojox.secure
[D]ADSafe
Show Answer
Correct Answer: ADSafe
Notes:
Answer: d
Explanation: ADsafe was one of the first security subsets proposed) It was created by Douglas Crockford (who also defined The Good Parts subset). ADsafe relies on static verification only, and it uses JSLint as its verifier. It forbids access to most global variables and defines an ADSAFE variable that provides access to a secure API, including special-purpose DOM methods. ADsafe is not in wide use, but it was an influential proof-of-concept that influenced other secure subsets.
222). Which is the subset that transforms web content into secure modules that can be safely hosted on a web page?
[A] Microsoft Web Sandbox
[B]ADsafe
[C]Caja
[D]dojox.secure
Show Answer
Correct Answer: dojox.secure
Notes:
Answer: d
Explanation: Caja is Google’s open-source secure subset. Caja (Spanish for “box”) defines two language subsets. Cajita (“little box”) is a narrow subset like that used by ADsafe and dojox.secure. Valija (“suitcase” or “baggage”) is a much broader language that is close to regular ECMAScript 5 strict mode (with the removal of eval()). Caja itself is the name of the compiler that transforms (or “cajoles”) web content (HTML, CSS, and JavaScript code) into secure modules that can be safely hosted on a web page without being able to affect the page as a whole or other modules on the page.
223). What will be the output of the following JavaScript code?
var set = new Set();
set.add("one");
set.add("two");
for (let elements of set)
{
document.writeln(elements+" ");
}
[A]one
[B]two
[C]one two
[D]undefined
Show Answer
Correct Answer: one two
Notes:
Answer: c
Explanation: The JavaScript Set add() method is used to add an element to Set object with a specified value. Each element must have a unique value.
224). What will be the output of the following JavaScript code?
set.add("AngularJS");
set.add("Bootstrap");
set.delete("Bootstrap");
document.writeln(set.size);
[A]2
[B]1
[C]0
[D]Undefined
Show Answer
Correct Answer: 1
Notes:
Answer: b
Explanation: The delete() method is used to remove all the elements from the Set object which are passed as an argument to the delete function. Since the delete function is called once the size will be reduced to 1.
225). What will be the output of the following JavaScript code?
set.add("one");
set.add("two");
set.add("three");
set.clear();
document.writeln(set.size);
Show Answer
Correct Answer: 0
Notes:
Answer: d
Explanation: JavaScript Set clear() method is used to remove all the elements from Set object. The clear method will remove all the entries and hence the size of the set will be zero.
226). What will be the output of the following JavaScript code?
set.add("one");
set.add("two”);
var itr=set.values();
document.writeln(itr.next().value);
[A]one
[B]two
[C]error
[D]undefined
Show Answer
Correct Answer: one
Notes:
Answer: a
Explanation: values() method returns an object of new Set iterator. This object contains the value for each element. It maintains insertion order.
227). What will be the output of the following JavaScript code?
set.add("1");
set.add("2");
document.writeln(set.has("3"));
[A]3
[B]true
[C]false
[D]2
Show Answer
Correct Answer: false
Notes:
Answer: c
Explanation: The Set has() method indicates whether the Set object contains the specified value. It returns true if the specified value is present, otherwise false.