Caching And Debugging - Study Mode
[#36] What is the purpose of the advanced mode in the closure compiler?
Correct Answer
(C) Both Renames variables and function
Explanation
Solution: In Advanced mode it rewrites the JavaScript by renaming variables and functions from longer descriptive names to single letters to save file size, and it inlines functions, coalescing them into single functions wherever it determines that it can.
[#37] Why is a closure template used?
Correct Answer
(C) Dynamically generating HTML in Java and JavaScript
Explanation
Solution: Closure Templates are a templating system for dynamically generating HTML in both Java and JavaScript. Because the language was apparently referred to as “Soy” internal to Google, and “Soy” remains in some of the documentation and classes, sometimes Closure Templates are referred to as “Soy Templates”.
[#38] In what way does the closure compiler help in checking the code?
Correct Answer
(A) Warnings
Explanation
Solution: The Closure Compiler provides warnings for illegal JavaScript and warnings for potentially dangerous operations, helping you to produce JavaScript that is less buggy and easier to maintain.
[#39] What is the function of the closure compiler?
Correct Answer
(C) Both Download faster and Run faster
Explanation
Solution: The Closure Compiler is a tool for making JavaScript download and run faster. It is a true compiler for JavaScript. Instead of compiling from a source language to machine code, it compiles from JavaScript to better JavaScript. It parses your JavaScript, analyzes it, removes dead code and rewrites and minimizes what’s left. It also checks syntax, variable references, and types, and warns about common JavaScript pitfalls.
[#40] What does the interpreter do when you reference variables in other scopes?
Correct Answer
(B) Traverses the stack
Explanation
Solution: Normally when you reference variables in other scopes— at the global level, in other namespaces, and so on—the interpreter needs to traverse the stack to get to the variable.