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
/* | |
given goals: | |
https://github.com/tc39/proposal-class-fields/blob/master/PRIVATE_SYNTAX_FAQ.md#why-is-encapsulation-a-goal-of-this-proposal | |
& given example: | |
https://github.com/tc39/proposal-class-fields/blob/master/PRIVATE_SYNTAX_FAQ.md#how-can-you-provide-hidden-but-not-encapsulated-properties-using-symbols | |
Hidden & encapsulated values can be shared with same instances via WeakMap & Proxies | |
Undesirable access via callbacks passed in & whatnot just need to be defended against. | |
One could imagine wanting to allow callbacks read access to privates but not write, doable w/a proxy & setup condition. |
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
/* | |
given goals: | |
https://github.com/tc39/proposal-class-fields/blob/master/PRIVATE_SYNTAX_FAQ.md#why-is-encapsulation-a-goal-of-this-proposal | |
& given example: | |
https://github.com/tc39/proposal-class-fields/blob/master/PRIVATE_SYNTAX_FAQ.md#how-can-you-provide-hidden-but-not-encapsulated-properties-using-symbols | |
Hidden & encapsulated values can be shared with same instances via WeakMap & Proxies | |
Undesirable access via callbacks passed in & whatnot just need to be defended against. | |
One could imagine wanting to allow callbacks read access to privates but not write, doable w/a proxy & setup condition. |
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
/* | |
https://github.com/tc39/proposal-class-fields/blob/master/PRIVATE_SYNTAX_FAQ.md#how-can-you-model-encapsulation-using-weakmaps | |
"There's a potential pitfall with this approach, though" | |
...so prevent it! | |
*/ | |
const Person = (function(){ | |
const privates = new WeakMap; | |
let ids = 0; | |
return class Person { | |
constructor(name, makeGreeting) { |
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
//guess what this outputs | |
var | |
varᅚ = 1, | |
ᅛ = 4, | |
ᅜ = 2, | |
ˋhey,ˋ=`B `,<!--#wtf | |
donˈtᅠworryǃ="(" | |
console.log(ˋhey,ˋ + donˈtᅠworryǃ + varᅚ*ᅛ*ᅜ) |
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
var echo=function(){ | |
var echoes=echo.count||10 | |
while(echoes--) this.makeNoise() | |
} | |
var dog={ | |
sound:"woof", | |
makeNoise:function(){ console.log(this.sound) }, | |
} |
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
var durations={} | |
,os={} | |
function aSet(){ | |
return new Promise((res,rej)=>{ | |
var N = n = 10, | |
m = 6 | |
while(m--) { | |
//increase keys | |
N *= 10 | |
n = N |
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
<html> | |
<head> | |
<script src="https://wzrd.in/standalone/nipplejs"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/peerjs/0.3.14/peer.min.js"></script> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> | |
</head> | |
<body> | |
<style> | |
body { |
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 ShowValidStartingIdentifierChars(){ | |
var validStarters={} | |
,max=130000 | |
,group=5000 | |
for(var i=0;i<max;i++){ | |
try{ | |
var s=String.fromCodePoint(i) | |
eval(`let ${s}=1`) | |
validStarters[s]=1 | |
} |