Programing Language Jargon: Reflection

By Xah Lee. Date: .

Why JavaScript Reflection is Not Reflection

Ok, let me give a deep dive of a concrete example why the so-called reflection is wrong think. This, is a example of reflection, in js, from wikip. Best illustration.

js reflection 2022-10-16
js reflection 2022-10-16
// Without reflection
const foo = new Foo();

// With reflection
const foo = Reflect.construct(Foo);
const hello = Reflect.get(foo, "hello");
Reflect.apply(hello, foo, []);

// With eval
eval("new Foo().hello()");

No let reflection taint your brain

Programing Jargons