chrisisgr8 on Nostr: new mildly cursed javascript thing i learned: you can write a function outside of a ...
new mildly cursed javascript thing i learned: you can write a function outside of a class scope that accesses instance fields (this.etc) and then assign that function to a field, then call it and have it work
class bitch{
constructor (){
this.asdf = hnngg;
this.stringy = ":3";
}
function hnngg{
alert(this.stringy);
}
bitch.asdf() would generate a :3 alert
Published at
2023-04-25 21:10:17Event JSON
{
"id": "2767d8ceb0c120b2120c1f8ab7786d6381f09f49ff35d4497eeb0c8836dc1724",
"pubkey": "eec2eeb21ba5ef7d2af72c4c766d61259e73d815c2e3db13a48dd9810e0bdfcf",
"created_at": 1682457017,
"kind": 1,
"tags": [
[
"mostr",
"https://tech.lgbt/users/chrisisgr8/statuses/110261503115909310"
]
],
"content": "new mildly cursed javascript thing i learned: you can write a function outside of a class scope that accesses instance fields (this.etc) and then assign that function to a field, then call it and have it work\n\nclass bitch{\nconstructor (){\nthis.asdf = hnngg;\nthis.stringy = \":3\";\n}\n\nfunction hnngg{\nalert(this.stringy);\n}\n\nbitch.asdf() would generate a :3 alert",
"sig": "f34ed9fae07704a10c726977b36284f84694348fba50b5eddf13a3ded0defdddb49380bf97531dbfda8052df616c478bbd5b2f3422f2e57e8cb846279f8bb872"
}