This file contains hidden or 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
| class Openable { | |
| constructor(isOpen = false) { | |
| this._isOpen = isOpen; | |
| } | |
| get isOpen() { | |
| return this._isOpen + ' is stupid.'; | |
| } |
This file contains hidden or 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 ClosedBracketWord(w='w') { | |
| return !w[19] && w.split('').every((l, i) => 122-(l.charCodeAt()-97) === w.charCodeAt(w.length-1-i)); | |
| } | |
| ClosedBracketWord('abiryz'); // true | |
| ClosedBracketWord('abixyz'); // false | |
| ClosedBracketWord('ABCXYZ'); // false | |
| ClosedBracketWord(''); // true |
This file contains hidden or 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
| TicTacToe = (board) => { | |
| let winbits = [7,56,73,84,146,273,292,448]; | |
| board = Array.prototype.concat.apply([], board); | |
| query = player => { | |
| num = 0; | |
| board.forEach((cell, i) => { | |
| var i = (board.length-i)-1; | |
| num += (cell === player)<<i; | |
| }); |
This file contains hidden or 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
| CanMakePalindrome = (s, b, o, t) => { | |
| t = s.length % 2; | |
| o = [...s].filter(l => { | |
| b = s.split(l); | |
| s = b.join``; | |
| return (b.length - 1)%2; | |
| }); | |
| return t ? (o.length === 1) : (o.length === 0); | |
| } |
This file contains hidden or 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 Counter = (function counter(i) { | |
| increment = function increment() { | |
| ++i; | |
| }; | |
| decrement = function decrement() { | |
| --i; | |
| }; |
This file contains hidden or 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 rgb = (function(red, blue, green) { | |
| return { | |
| red: red, | |
| blue: blue, | |
| green: green | |
| }; | |
| }); | |
| var rgb1 = rgb(0, 0, 0); // colour to use | |
| var rgb2 = rgb(255, 255, 255); // background colour |
This file contains hidden or 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> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Object Composition</title> | |
| </head> | |
| <body> | |
| <h1> | |
| <a class="first" href="#">First</a> | |
| <a class="second" href="#">Second</a> |
This file contains hidden or 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
| // Font Loaded | |
| (function fontLoaded() { | |
| var retries = 300; | |
| function checkReady() { | |
| var canvas, | |
| context; | |
| retries -= 1; | |
| canvas = document.createElement('canvas'); | |
| canvas.width = 20; |
This file contains hidden or 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 MyElement = new function MyElement() { | |
| var obj = Object.create(HTMLElement.prototype); | |
| var self = { | |
| createdCallback: function createdCallback() { | |
| console.log('createdCallback', this); | |
| }, | |
| attachedCallback: function attachedCallback() { | |
| console.log('attachedCallback', this); | |
| }, |
OlderNewer