Skip to content

Instantly share code, notes, and snippets.

@lexeek
Last active December 21, 2018 13:50
Show Gist options
  • Save lexeek/f8cb4742fdd3c8dd16a133e6d93daca0 to your computer and use it in GitHub Desktop.
Save lexeek/f8cb4742fdd3c8dd16a133e6d93daca0 to your computer and use it in GitHub Desktop.
Result
index: 0, key: index-0, year: 2018
index: 1, key: index-1, year: 2018
index: 2, key: index-2, year: 2018
index: 3, key: index-3, year: 2018
index: 4, key: index-4, year: 2018
index: 5, key: index-5, year: 2018
index: 6, key: index-6, year: 2018
index: 7, key: index-7, year: 2018
index: 8, key: index-8, year: 2018
index: 9, key: index-9, year: 2018
// Исправить код, чтобы получить соответствующий лог.
// Исправить код функций, доступны любые изменения внутри кода функций, обращать внимание на все ), изучаем call, bind и тп
// Единственное не менять значения проинициализированных объектов
(function() {
'use strict';
var myFistBestObjectVariableOfJS = {message: 'RESULT:'};
let myBestObject = new Object({0: 0});
let array = new Array(1);
function objectKey() {
this.year = arguments[0];
print.call(print, arguments[2].call(null, arguments[1]));
}
function callFn(obj) {
for (var key of obj) {
objectKey( new Date().getUTCFullYear(), key, obj[key]);
}
}
var myFirstBestCycleFunctionOfThisYear = function() {
for (var i = 0; i < array.length; i++) {
myBestObject['index-' + i] = function(key) {
this.i = `index: ` + i + ', key: ' + key + ', year: ' + this.year;
return this.i
}.bind(null)
}
callFn(myBestObject);
};
function print(value) {
return console.log(this.message, '', value)
}
myFirstBestCycleFunctionOfThisYear();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment