xtodo JavaScript js

xtodo
xtodo
xtodo

// 2026-01-13
// from
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Segmenter

const xx = "吾輩は猫である。名前はたぬき。";
const segmenterJa = new Intl.Segmenter("ja-JP", { granularity: "word" });
const xresult = segmenterJa.segment(xx);
console.log(Array.from(xresult));
/*
[
  {
    segment: "吾輩",
    index: 0,
    input: "吾輩は猫である。名前はたぬき。",
    isWordLike: true
  },
  {
    segment: "は",
    index: 2,
    input: "吾輩は猫である。名前はたぬき。",
    isWordLike: true
  },
  {
    segment: "猫",
    index: 3,
    input: "吾輩は猫である。名前はたぬき。",
    isWordLike: true
  },
  {
    segment: "で",
    index: 4,
    input: "吾輩は猫である。名前はたぬき。",
    isWordLike: true
  },
  {
    segment: "ある",
    index: 5,
    input: "吾輩は猫である。名前はたぬき。",
    isWordLike: true
  },
  {
    segment: "。",
    index: 7,
    input: "吾輩は猫である。名前はたぬき。",
    isWordLike: false
  },
  {
    segment: "名前",
    index: 8,
    input: "吾輩は猫である。名前はたぬき。",
    isWordLike: true
  },
  {
    segment: "は",
    index: 10,
    input: "吾輩は猫である。名前はたぬき。",
    isWordLike: true
  },
  {
    segment: "たぬき",
    index: 11,
    input: "吾輩は猫である。名前はたぬき。",
    isWordLike: true
  },
  {
    segment: "。",
    index: 14,
    input: "吾輩は猫である。名前はたぬき。",
    isWordLike: false
  }
]
*/

console.table(Array.from(xresult));

/*
┌───────┬──────────┬───────┬──────────────────────────────────┬────────────┐
│ (idx) │ segment  │ index │ input                            │ isWordLike │
├───────┼──────────┼───────┼──────────────────────────────────┼────────────┤
│     0 │ "吾輩"   │     0 │ "吾輩は猫である。名前はたぬき。" │ true       │
│     1 │ "は"     │     2 │ "吾輩は猫である。名前はたぬき。" │ true       │
│     2 │ "猫"     │     3 │ "吾輩は猫である。名前はたぬき。" │ true       │
│     3 │ "で"     │     4 │ "吾輩は猫である。名前はたぬき。" │ true       │
│     4 │ "ある"   │     5 │ "吾輩は猫である。名前はたぬき。" │ true       │
│     5 │ "。"     │     7 │ "吾輩は猫である。名前はたぬき。" │ false      │
│     6 │ "名前"   │     8 │ "吾輩は猫である。名前はたぬき。" │ true       │
│     7 │ "は"     │    10 │ "吾輩は猫である。名前はたぬき。" │ true       │
│     8 │ "たぬき" │    11 │ "吾輩は猫である。名前はたぬき。" │ true       │
│     9 │ "。"     │    14 │ "吾輩は猫である。名前はたぬき。" │ false      │
└───────┴──────────┴───────┴──────────────────────────────────┴────────────┘
*/
xtodo
xtodo
xtodo

make functional programing example

xtodo
  • search “Function form lets you manipulate expressions”. e.g. reflect.get page. create a new page showing example. and all pages link to it.
xtodo
xtodo
xtodo
xtodo
xtodo
xtodo
xtodo
xtodo
YouTube stars flying 2025-05-12
YouTube stars flying 2025-05-12
xtodo
xtodo
xtodo
js iterator 2025-04-26 192d7
js iterator 2025-04-26 192d7
const xx = Array(4).fill(0).map((x, i) => x + i);
console.log(xx);
// [ 0, 1, 2, 3 ]

// yy = xx[Symbol.iterator];

// console.log( yy )

// console.log( yy() .next() )

console.log( xx[Symbol.iterator]().next(), );
// { value: 0, done: false }

console.log( xx[Symbol.iterator]().next(), );
// { value: 0, done: false }

/*
the complex javascript iterator generator interface fucks.

here, first is the complexity of no range function.
you got the fill method patch to deal with that.

then, am trying to deconstruct the iteratable interface, trying to get its next value.
but apparantly it resets.

very complex, because the iterable contains a property of type symbol, named Symbol.iterator.
it's value must be a function.
and it must return a object, this object must have a next property, and this property's value must be a function.
this is why u get this funky
xx[Symbol.iterator]().next()

its return value, is a object, that contains value and done keys.

yet, somehow it resets. am unable to get it to 0, 1, 2, 3, etc.
 */
xtodo
xtodo
xtodo

JavaScript

Georrg, 11/03/2022 @XahLee standard library has walk and walkSync functions

import { walkSync } from "https://deno.land/std@0.162.0/fs/walk.ts";

for (const entry of walkSync(".")) {
console.log(entry.path);
}
js TypeScript george 2022-04-19
JavaScript TypeScript george 2022-04-19
js todo 2021-11-21 tmKkW
JavaScript todo 2021-11-21 tmKkW
xtodo

missing some. create new page for them.

xtodo

js this-binding argument

bryan forbs js 2026-02-01 2a969
bryan forbs js 2026-02-01 2a969
// nasty problem in JavaScript involving this-binding

function MakeObj(x) {
this.p = x;
return "lol";
}

function OhMyGodMakeObj(x) {
this.p = x;
return {};
}

const niceObj = new MakeObj(3);
console.assert(niceObj.p === 3);

const godObj = new OhMyGodMakeObj(3);
console.assert(godObj.p === 3, "omg, no work");
// Assertion failed: omg, no work
// oddity in JavaScript involving this-binding.
// a magic “this” bultin var, nothing to do with object oriented programing.

function addone(x) {
return this + x;
}

console.assert(addone.call(3, 4) === 7);

/*
this means, people can write all functions this way,
and the new call syntax is
funname.call(args...)
instead of just
funname.(args...)
*/

/*

the problem here is, in typical programing engineering fashion of speaking, JavaScript leaked the this-binding mechanism for its so-called dispatch in its object-oriented way.

it should generate a error instead, when function use this-binding without being a method.

*/

todo stuff