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
var add = function add() { | |
var args = Array.prototype.slice.call(arguments); | |
var fn = Function.prototype.bind.apply(add, [null].concat(args)); | |
fn.valueOf = function() { | |
return args.reduce(function(a, b) { | |
return a + parseInt(b); | |
}, 0); | |
}; | |
return fn; | |
} |
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
<?php | |
require __DIR__ . '/vendor/autoload.php'; | |
use Keygen\Keygen; | |
// Prefix (inclusive enabled) | |
echo Keygen::numeric(12)->prefix('TM-')->generate(); // e.g TM-218624395 | |
// Prefix (inclusive disabled) | |
echo Keygen::numeric(12)->prefix('TM-')->generate(true); // e.g TM-382104609735 |
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
<?php | |
require __DIR__ . '/vendor/autoload.php'; | |
use Keygen\Keygen; | |
$splitString = function($key) { | |
return join('-', str_split($key, 4)); | |
}; | |
$shortHash20 = function($key) { |
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
<?php | |
require __DIR__ . '/vendor/autoload.php'; | |
use Keygen\Keygen; | |
$id_12 = Keygen::numeric(12)->generate(); | |
$id_16 = Keygen::numeric()->generate(); | |
$alnum = Keygen::alphanum(15)->generate(); | |
$token = Keygen::token(28)->generate(); |
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
const student = { | |
name: 'John Doe', | |
age: 16, | |
scores: { | |
maths: 74, | |
english: 63, | |
science: 85 | |
} | |
}; |
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
function displaySummary({ name, scores: { maths = 0, english = 0, science = 0 } }) { | |
console.log('Hello, ' + name); | |
console.log('Your Maths score is ' + maths); | |
console.log('Your English score is ' + english); | |
console.log('Your Science score is ' + science); | |
} |
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
const student = { | |
firstname: 'Glad', | |
lastname: 'Chinda', | |
country: 'Nigeria' | |
}; | |
// Object Destructuring | |
const { firstname, lastname, country } = student; | |
console.log(firstname, lastname, country); // Glad Chinda Nigeria |
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
const person = { | |
name: 'John Doe', | |
country: 'Canada' | |
}; | |
// Assign default value of 25 to age if undefined | |
const { name, country, age = 25 } = person; | |
// Here I am using ES6 template literals | |
console.log(`I am ${name} from ${country} and I am ${age} years old.`); |
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
const person = { | |
name: 'John Doe', | |
country: 'Canada' | |
}; | |
// Assign default value of 25 to years if age key is undefined | |
const { name: fullname, country: place, age: years = 25 } = person; | |
// Here I am using ES6 template literals | |
console.log(`I am ${fullname} from ${place} and I am ${years} years old.`); |
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
const student = { | |
name: 'John Doe', | |
age: 16, | |
scores: { | |
maths: 74, | |
english: 63 | |
} | |
}; | |
// We define 3 local variables: name, maths, science |
OlderNewer