Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View viswesh's full-sized avatar

Viswesh Subramanian viswesh

View GitHub Profile
@viswesh
viswesh / manifest.json
Created September 24, 2017 15:25
Web App Manifest sample file.
{
"name": "JavaScript Store",
"short_name": "JavaScript Store",
"lang": "en-US",
"start_url": "/",
"display": "fullscreen",
"orientation": "portrait",
"theme_color": "#f2e058",
"icons": [
{
@viswesh
viswesh / proxyandreflect.js
Created September 21, 2017 18:35
Sample code for demonstrating Proxy and Reflect usage.
function propDefaults(defaults) {
const handler = {
get (obj, prop) {
return Reflect.get(obj, prop) || defaults[prop];
}
};
return new Proxy({}, handler);
}
const palette = propDefaults({color: "yellow"});
@viswesh
viswesh / jspromisses.js
Last active March 4, 2018 03:51
JavaScript promise sample
let promise = new Promise((resolve, reject) => {
//invoke async operation, then
if (/* success */) {
resolve("response received! Success!");
} else {
reject(Error("Something failed"));
}
});
promise.then(function(result) {
@viswesh
viswesh / es6templatestrings.js
Created September 11, 2017 02:11
ES6 Template Strings
displayFeatures() {
  this._features.forEach((feature, index) => console.info(`${this._language} feature ${index} ${feature}`))
}
@viswesh
viswesh / es6iterators.js
Created September 11, 2017 02:09
ES6 Iterators sample
let s = “Hello”;
let sIterator =  s[Symbol.iterator]();
console.info( sIterator.next().value ) //H
console.info( sIterator.next().value ) //e
console.info( sIterator.next().value ) //l
@viswesh
viswesh / es6arrows.js
Last active September 11, 2017 02:21
ES6 Arrow sample
var store = {
  _language: “JavaScript”,
   _features: [],
   displayFeatures() {
     this._features.forEach((feature, index) =>console.info(this._language + feature + index+ “ ”+ feature))
   }
}
@viswesh
viswesh / es6class.js
Last active March 7, 2019 18:06
ES6 Class
class Person { //instance method
speak() {
console.log(‘speak’);
}
}
class Person { //static method
static isHuman() {}
}
class Person { //initialize instances
constructor(arguments) {}