Show newer

@aescling @wallhackio @Satsuma yes but ultimately it boils down to a GetValue which calls ToObject on the value and then does a property lookup on the result using the original value as the this value (in case the property uses a getter)

and THEN in the case of a method call does a Call on the result again using the original value as the this value

(so it's actually

Reflect.get(new Object("foo"), "toString", "foo").call("foo")

); i overly simplified before

@aescling @wallhackio @Satsuma not QUITE because the this value when calling methods is the original literal not the object-wrapped form

@wallhackio @Satsuma so what you are thinking of as “numbers and strings” is actually “object-wrapped numbers and strings” which do indeed have the internal slots that you describe

but what is in those internal slots? the original immutable number and string literals

@wallhackio @Satsuma the confusion is that for all of these things Javascript is doing `new Object(…)` behind the scenes, so that

"foo".toString()

is literally

new Object("foo").toString.call("foo");

"foo" itself is not an object, javascript just does a lot of behind-the-scenes object wraps in necessary places to make it work like one in many cases

@wallhackio @Satsuma this is also why you can't do

const foo = "foo";
foo.bar = "baz";

and have it be sensible; but you can do

const foo = new String("foo");
foo.bar = "baz";

without issue

@wallhackio @Satsuma no, strings, numbers, etc in javascript are explicitly not objects, they are literal (immutable) values

this is why `"foo" === String("foo")` but `"foo" !== new String("foo")`; the result of a new expression is always an object, whereas the result of `String("foo")` is a literal string value

cf. the `typeof` operator

the purpose of valueOf is to get the literal value of a wrapped object type, so `"foo" === (new String("foo")).valueOf()`

@wallhackio @Satsuma honestly thinking everything is an object is imagining javascript to be simpler and more consistent than it actually is

¡oye @wallhackio, ¿alguna vez ha escuchando la MODA como te sugerí?

@alyssa yo sabía el idioma bastante bien en colegio secondario pero hace pasado mucho tiempo

@Satsuma sace muchas clases de español pero sus profesoras fueron muy malas

@aescling no sabe nada de español pero ella cree qué debería

@alyssa @aescling @Satsuma estoy jugando pokémon leyendas arceus en español y ha snowballed

pero, sí

@coriander @aescling @wallhackio we were debating whether caleb knew the difference between this and someone who listens to metal

they call it “bigatito”… despite the fact it is a perfectly normally sized sprigatito…

Show older
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.