Created
May 10, 2017 15:17
-
-
Save abdu95/8a182411a63bf6ad0cc207df984833d6 to your computer and use it in GitHub Desktop.
Detect JavaScript Data Types // source http://jsbin.com/muvoweyiwa
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>Detect JavaScript Data Types</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
function show_type(arg){ | |
return typeof arg; | |
} | |
console.log(show_type(5)); | |
console.log(show_type("heroina")); | |
console.log(show_type(null)); | |
console.log(show_type(function(){})); | |
console.log(show_type(new Date())); | |
console.log(show_type(false)); | |
console.log(show_type(undefined)); | |
var d = new Date(); | |
document.write(d); | |
function find_low(arr){ | |
arr.sort(function(a,b){return a - b;}); | |
if(arr.length>2){ | |
return arr[1] + " ," + arr[arr.length -2]; | |
}else{ | |
return arr[1]; | |
} | |
} | |
console.log(find_low([100, 40])); | |
console.log(find_low([1, 5, 10, 25, 40, 100])); | |
console.log(find_low([5, 1, 25, 40, 10, 100])); | |
function perfect(numb){ | |
} | |
var sum = [1, 2, 3].reduce((a, b) => a + b, 0); | |
console.log(sum); // 6 | |
/*Write a JavaScript function to | |
convert an amount to coins. Go to the editor | |
Sample function : amountTocoins(46, [25, 10, 5, 2, 1]) | |
Here 46 is the amount. and 25, 10, 5, 2, 1 are coins. | |
Output : 25, 10, 10, 1*/ | |
//another | |
function powerBank(number, power){ | |
return Math.pow(number, power); | |
} | |
console.log(powerBank(4, 0)); | |
function stringify(arg){ | |
} | |
function random_characters(amount){ | |
var text = " "; | |
var charset = "abcdefghijklmnopqrstuvwxyz0123456789"; | |
for( var i=0; i < amount; i++ ) | |
text += charset.charAt(Math.floor(Math.random() * charset.length)); | |
return text; | |
} | |
console.log(random_characters(3)); | |
function comb(_array, _number){ | |
var n = _array.length; | |
function factorial(n) { | |
return (n != 1) ? n * factorial(n - 1) : 1; | |
} | |
//return _array.length + _number; | |
} | |
console.log(comb([1, 2, 4], 2)); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">function show_type(arg){ | |
return typeof arg; | |
} | |
console.log(show_type(5)); | |
console.log(show_type("heroina")); | |
console.log(show_type(null)); | |
console.log(show_type(function(){})); | |
console.log(show_type(new Date())); | |
console.log(show_type(false)); | |
console.log(show_type(undefined)); | |
var d = new Date(); | |
document.write(d); | |
function find_low(arr){ | |
arr.sort(function(a,b){return a - b;}); | |
if(arr.length>2){ | |
return arr[1] + " ," + arr[arr.length -2]; | |
}else{ | |
return arr[1]; | |
} | |
} | |
console.log(find_low([100, 40])); | |
console.log(find_low([1, 5, 10, 25, 40, 100])); | |
console.log(find_low([5, 1, 25, 40, 10, 100])); | |
function perfect(numb){ | |
} | |
var sum = [1, 2, 3].reduce((a, b) => a + b, 0); | |
console.log(sum); // 6 | |
/*Write a JavaScript function to | |
convert an amount to coins. Go to the editor | |
Sample function : amountTocoins(46, [25, 10, 5, 2, 1]) | |
Here 46 is the amount. and 25, 10, 5, 2, 1 are coins. | |
Output : 25, 10, 10, 1*/ | |
//another | |
function powerBank(number, power){ | |
return Math.pow(number, power); | |
} | |
console.log(powerBank(4, 0)); | |
function stringify(arg){ | |
} | |
function random_characters(amount){ | |
var text = " "; | |
var charset = "abcdefghijklmnopqrstuvwxyz0123456789"; | |
for( var i=0; i < amount; i++ ) | |
text += charset.charAt(Math.floor(Math.random() * charset.length)); | |
return text; | |
} | |
console.log(random_characters(3)); | |
function comb(_array, _number){ | |
var n = _array.length; | |
function factorial(n) { | |
return (n != 1) ? n * factorial(n - 1) : 1; | |
} | |
//return _array.length + _number; | |
} | |
console.log(comb([1, 2, 4], 2));</script></body> | |
</html> |
This file contains hidden or 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
function show_type(arg){ | |
return typeof arg; | |
} | |
console.log(show_type(5)); | |
console.log(show_type("heroina")); | |
console.log(show_type(null)); | |
console.log(show_type(function(){})); | |
console.log(show_type(new Date())); | |
console.log(show_type(false)); | |
console.log(show_type(undefined)); | |
var d = new Date(); | |
document.write(d); | |
function find_low(arr){ | |
arr.sort(function(a,b){return a - b;}); | |
if(arr.length>2){ | |
return arr[1] + " ," + arr[arr.length -2]; | |
}else{ | |
return arr[1]; | |
} | |
} | |
console.log(find_low([100, 40])); | |
console.log(find_low([1, 5, 10, 25, 40, 100])); | |
console.log(find_low([5, 1, 25, 40, 10, 100])); | |
function perfect(numb){ | |
} | |
var sum = [1, 2, 3].reduce((a, b) => a + b, 0); | |
console.log(sum); // 6 | |
/*Write a JavaScript function to | |
convert an amount to coins. Go to the editor | |
Sample function : amountTocoins(46, [25, 10, 5, 2, 1]) | |
Here 46 is the amount. and 25, 10, 5, 2, 1 are coins. | |
Output : 25, 10, 10, 1*/ | |
//another | |
function powerBank(number, power){ | |
return Math.pow(number, power); | |
} | |
console.log(powerBank(4, 0)); | |
function stringify(arg){ | |
} | |
function random_characters(amount){ | |
var text = " "; | |
var charset = "abcdefghijklmnopqrstuvwxyz0123456789"; | |
for( var i=0; i < amount; i++ ) | |
text += charset.charAt(Math.floor(Math.random() * charset.length)); | |
return text; | |
} | |
console.log(random_characters(3)); | |
function comb(_array, _number){ | |
var n = _array.length; | |
function factorial(n) { | |
return (n != 1) ? n * factorial(n - 1) : 1; | |
} | |
//return _array.length + _number; | |
} | |
console.log(comb([1, 2, 4], 2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment