Determining how experienced and knowledgeable a programmer is takes more than a cursory evaluation of a résumé. Probing and analytical questions go a long way toward evaluating a candidate’s skill level.
Why Use Loops at All, and What Types to Use
There are various types of loops utilized in programs, for specific purposes. Experienced programmers should be able to define the types and uses of each form:
- FOR loop – executes a group of code multiple times
- FOR/IN loop – loops depending on the properties of a particular object
- DO/WHILE loop – executes a block of logic while a condition specified is true
- WHILE loop – loops through a block of code while a set condition is true
Loops will ultimately make use of variables in their function to control execution of the logic. Each function of code can create its own variables, which could be defined as local or global variables. Local variables (those created in a function) are not available outside their function, where global variables can be accessed across functions – outside their scope.
A good description of closures is to illustrate how they can be used to ‘hide’ data used in one function from another object or function. By utilizing object oriented programming (OOP) techniques, variables and data utilized within one function can be isolated or encapsulated from other functions.
Loop functions are therefore good uses for closures, where a developer may want a particular function to have access to only certain data or variables, but keep other information private.
This can be particularly useful in web applications and server functions that may be available to many users or even in the public domain, where there is function data that must be protected from access to such objects as public APIs.
Why use strict mode?
Programmers can avoid potential coding errors through the use of strict mode:
- Assignment to getter-only or non-writable properties
- Reference to a non-existing property or variable
- Use of an object that does not exist
Since objects are also variables, strict mode disallows the use of any object that has not been declared, and prevents deletion of an object or variable.
Use strict is supported by IE V10 and higher, Firefox V4 and up, and Chrome since V13.
Understanding Coercion – Does Your Candidate?
Getting the Right Answers