JSFiddle - React, Tailwind, and code Playground
by ronnjoe
HTML
<div id="box1">
sfdsfsfsf
<div id="box2">
fsfdsf
<div id="box3">
ddssfdsfs
</div>
</div>
</div>
<div id="content">
</div>
JavaScript
function abc(){
console.log("hello");
}
function hello(name, age) {
return function() {
console.log("in return function");
abc();
}
}
function hello(name, age) {
return function() {
console.log("in return function");
abc();
}
}
let work = hello("John", 33);
let works = hello("Johns", 33);
console.log(works());
var array = [
function(callback) {
console.log("first function called in " + (new Date().getTime() - timestamp) + "ms");
callback();
},
function(callback) {
console.log("second function called in " + (new Date().getTime() - timestamp) +
"ms");
callback();
},
function(callback) {
console.log("third function called in " + (new Date().getTime() - timestamp) + "ms");
callback();
}
],
timestamp = new Date().getTime();
var fetchData = function () {
return new Promise(function (resolve, reject) {
resolve();
});
}
var MyApp = {
isFunctionCompleted : false
};
function flow(array, callback) {
/* array.map(function(item,index){
//item.full_name = [item.first_name,item.last_name].join(" ");
if((array.length -1) === index){
MyApp.isFunctionCompleted = true
}
return item(callback);
}); */
/* array.forEach((item, index, array) => {
//fetchData(array1[array1.length -1]).then(function () {
//return item(callback);
//});
if((array.length -1) === index){
//fetchData(array1[array1.length -1]).then(item(callback));
MyApp.isFunctionCompleted = true
}
item(callback);
}); */
}
flow(array, function() {
if(MyApp.isFunctionCompleted){
console.log("all functions finished in " + (new Date().getTime() - timestamp) + "ms");
}
});
function isArray(array,callback){
var arrayType = (typeof(array) === "object" && (array instanceof Array));
try {
return (typeof(callback) ===undefined)?arrayType:(callback(arrayType));
} catch (e){
console.log(e);
} finally {
return arrayType;
}
//return (typeof(callback)...