Created
December 21, 2018 13:31
-
-
Save lexeek/25c9d2fb94bfe8f29fda4b44f93131c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
(function() { | |
'use strict'; | |
var myFistBestObjectVariableOfJS = {m: 'Middle', l: 'Last', f: 'First',}; | |
let myBestObject = new Object({0: 0}); | |
let array = new Array(10); | |
function objectKey() { | |
this.year = arguments[0]; | |
print(arguments[2].call(null, arguments[1])); | |
} | |
function callFn(obj) { | |
for (var key in obj) { | |
objectKey.call(null, 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(value) | |
} | |
myFirstBestCycleFunctionOfThisYear(); | |
})(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment