Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

> You cannot override that in Javascript

True. But you they can use a "known Symbol" to implement this feature.



sort by: page size:

Why is that allowed? I didn’t realize one could do that in js.

> With substitution variables/text, this feature could be amazing.

At which point, are you just re-creating JavaScript?


Javascript (with ECMAScript 6) supports symbols as a datatype.

Wait you can what!?? Holy moly, I've been writing JS for like 3 years now and I never knew this.

>JavaScript

...


> written in Javascript

Right there.


spoiler: yes in js it can

now that you know the answer try to come up with a solution.


It's been shown you can write pretty much any javascript code using operator symbols only (so things like +[]_) without any alphanumeric characters making it pretty much imposible to filter.

User inputed javascript is pretty much impossible to make safe.


Wow. That's news to me.

I wonder what else is in the JS syntax that I've been missing out on!


I had to read that paragraph several times to see if they said "But Javascript doesn't do this." Nope, not in there at all.

I had no ideas this was an option in JavaScript.

Fun read.


As someone who has only had a cursory learning of JavaScript, I predicted correctly. The concept of overriding is known to me, although it's clearly in a slightly different context here and that 010 is 8 in octal I knew since I learned C.

I gather that JavaScript has a lot of quirks (eg: '==' vs '===' if I'm not mistaken) but I don't feel like these are too.


Why is everyone claiming this is impossible in JavaScript? If you have a POC you should post it so others can learn of the danger.

You've even been quoted elsewhere in this thread about this topic.


FWIW, you can use `Symbol.for` to reuse symbols in JS (`Symbol.for("a") === Symbol.for("a")` is true).

>R is fudging numbers?

I said javascript fudges numbers, not R.


But because I'm not very familiar with Javascript, so I don't know if my thought is wrong or not.

So, If this thought is wrong, please tell me. Thanks.


> in javascript

Spotted your problem.


Oh. Never mind.

I somehow had it confused with a JavaScript implementation. Not sure how I had that misconception in my head.


You can't replace a complex concept with a boolean. This isn't JavaScript.
next

Legal | privacy