June 2018
Beginner
288 pages
6h 31m
English
let does not permit redefinition of variables, but it allows changing the value held in the variable. Without executing it, eyeball the following code to determine what the output will be.
| | 'use strict'; |
| | let factor = 2; |
| | |
| | let product = function(number) { |
| | return number * factor; |
| | }; |
| | |
| | factor = 0; |
| | |
| | console.log(product(4)); |
Show the code to your colleagues nearby or far away—what good is technology if you can’t bother someone with it—and ask them to determine the output. Did you or your colleagues gasp, shout out an answer, ending with “right?!” Were there inconsistency in the answers? Is the trouble worth it?
You might think that the result of the call to produce(4) should be 8. That ...
Read now
Unlock full access