Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
What is a Polyfill
How to create a Polyfill
NOT recommended on DOM Objects
Array - justLetter - only keep
Strings with a specific letter
Date - f$$kinDay - return the day
of the week with prefix
let log = console.log;
if(! Array.prototype.sort){
log('sort does not exist');
if(! Array.prototype.justLetter ){
//log('justLetter method missing')
Array.prototype.justLetter = function(letter){
let arr = this.filter((item)=>{
if(typeof item != 'string') return false;
return item.indexOf(letter) > -1;
return arr;
let names = ['abc', 'def', {'a':1}, 'cab', 'dac', 123];
log( names );
log( names.justLetter('d') );
if( ! Date.prototype.f$$kinDay ){
//log('f$$kinDay method missing')
Date.prototype.f$$kinDay = function(){
case 0:
return 'Today is f$$ckin Sunday';
case 1:
return 'Today is f$$ckin Monday';
case 2:
return 'Today is f$$ckin Tuesday';
case 3:
return 'Today is f$$ckin Wednesday';
case 4:
return 'Today is f$$ckin Thursday';
case 5:
return 'Today is f$$ckin Friday';
case 6:
return 'Today is f$$ckin Saturday';
log( new Date().f$$kinDay() )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.