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 Animal(name, weight) { | |
this.name = name; | |
this.weight = weight; | |
} | |
Animal.prototype.eat = function() { | |
return `${this.name} is eating!`; | |
} | |
Animal.prototype.sleep = function() { |
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
// ES6 style | |
class Animal { | |
constructor(name, weight) { | |
this.name = name; | |
this.weight = weight; | |
} | |
//... | |
} | |
// Check Type of ES6 class |
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
// ES6 style | |
class Animal { | |
// ... | |
eat() { | |
return `${this.name} is eating!`; | |
} | |
sleep() { | |
return `${this.name} is going to sleep!`; | |
} |
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
// ES6 style | |
class Gorilla extends Animal { | |
constructor(name, weight) { | |
super(name, weight); | |
} | |
//... | |
} | |
// Traditional style | |
function Gorilla(name, weight) { |
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
// ES6 style | |
class Gorilla extends Animal { | |
constructor(name, weight) { | |
super(name, weight); | |
} | |
showVigour() { | |
return `${super.eat()} ${this.poundChest()}`; | |
} |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title> App Shell </title> | |
<style> | |
/* Critical Inline Styles */ |
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 () { | |
class App { | |
constructor() { | |
this.registerServiceWorker(); | |
this._app = document.querySelector('.app'); | |
this.fetchOfflineContent = this.fetchOfflineContent.bind(this); | |
this.fetchAppContent = this.fetchAppContent.bind(this); | |
self.addEventListener('online', this.fetchAppContent); | |
self.addEventListener('offline', this.fetchOfflineContent); |
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 staticCacheName = 'app-shell-static-v1'; | |
const staticCacheFileNames = [ | |
'public/offline.html', | |
'lib/app.js' | |
]; | |
self.addEventListener('install', (event) => { | |
self.skipWaiting(); | |
event.waitUntil( |
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
if (!String.prototype.startsWith) { | |
String.prototype.startsWith = function (searchString, position) { | |
position = position || 0; | |
return this.substr(position, searchString.length) === searchString; | |
}; | |
} |
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
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () { | |
// Define the storage type (local or session) | |
var Storage = function (type) { | |
// Define the storage type (local or session) | |
function setData(data) { | |
// Sets the data into storage | |
} | |
function clearData() { | |
// clears data from storage | |
} |
OlderNewer