El objetivo del ejercicio es comprender que es lo que ocurre en cada segmento de código. Todos están relacionados al tema aunque algunos más que otros.
1.
(function test(){ console.log('ok'); })
test();
2.
test()
function test(){ console.log('ok'); }
3.
(function test(t = eval('var t = 1;')){
console.log(t);
})();
4.
(function test(t = eval('var c = 1;')){
console.log(c);
var c = 0;
})();
5.
(function test(){
x();
function x(){ console.log(1); };
function x(){ console.log(2); };
})();
6.
(function test(){
x();
function x(){ console.log(1); };
{
x();
function x(){ console.log(2); };
}
x();
})();
7.
new class {
constructor() {
x();
function x(){ console.log(1); }
function x(){ console.log(2); }
}
}
8.
new class {
constructor() {
function x(){ console.log(1); }
{
function x(){ console.log(2); }
}
x();
}
}
9.
new class {
constructor() {
{
function x(){ console.log('ok'); }
}
x();
}
}
10.
new class {
constructor() {
{
function x(){ console.log(1); }
function x(){ console.log(2); }
x();
}
}
}
11.
(function test(c){
var c;
console.log('ok');
})();
12.
(function test(c){
let c;
console.log('ok');
})();
13.
(function test(){
var c;
var c;
console.log('ok');
})();
14.
(function test(c, c){
console.log(c);
})(1,2);
15.
(function test(c, c = 2){
console.log(c);
})(1);
16.
(function test(){
console.log(arguments);
})();
17.
(() => console.log(arguments))();
18.
(function test(arguments){
console.log(arguments);
})();
19.
(function test(...c){
console.log(arguments);
})();
20.
(function test(){
let arguments;
console.log(arguments);
})();
21.
(function test(){
var arguments;
console.log(arguments);
})();
22.
(function test(){
var c;
let c;
})();
23.
(function test(){
var c;
{
let c;
}
})();
24.
(function test(){
let c;
{
var c;
}
})();
25.
(function test(){
let c;
if(false){
var c;
}
})();
Las respuestas las publicare a lo largo del día.
Edit: Quizás el tema vaya mejor en Desafios - Wargames o en Scripting. Pero algunas de las preguntas están relacionadas con Desarrollo Web (y esto es decir mucho).