D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
kyleshevlin
Full window
Github gist
JS Bin // source http://jsbin.com/yumoyat
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width"> <title>JS Bin</title> </head> <body> <script id="jsbin-javascript"> 'use strict'; function Stack() { this.storage = ''; } Stack.prototype.push = function (val) { if (this.storage.length === 0) { this.storage = val; } else { this.storage = this.storage + '---' + val; } }; Stack.prototype.pop = function () { var items = this.storage.split('---'); var val = items.pop(); this.storage = items.join('---'); return val; }; Stack.prototype.size = function () { return this.storage.split('---').length; }; var myWeeklyMenu = new Stack(); myWeeklyMenu.push('Red Beans'); myWeeklyMenu.push('Ranch Skillet'); console.log(myWeeklyMenu.storage); console.log(myWeeklyMenu.size()); var meal = myWeeklyMenu.pop(); console.log(meal); </script> <script id="jsbin-source-javascript" type="text/javascript">function Stack () { this.storage = '' } Stack.prototype.push = function (val) { if (this.storage.length === 0) { this.storage = val } else { this.storage = this.storage + '---' + val } } Stack.prototype.pop = function () { const items = this.storage.split('---') const val = items.pop() this.storage = items.join('---') return val } Stack.prototype.size = function () { return this.storage.split('---').length } const myWeeklyMenu = new Stack() myWeeklyMenu.push('Red Beans') myWeeklyMenu.push('Ranch Skillet') console.log(myWeeklyMenu.storage) console.log(myWeeklyMenu.size()) const meal = myWeeklyMenu.pop() console.log(meal);</script></body> </html>