Explain yourselves javascriptcels

40
Jump in the discussion.

No email address required.

Some things:

1. In JS, the bracket syntax is just an alternative way of accessing a property. something.prop is the same as something['prop'], but JS parsing rules don't allow you to use the dot syntax with numbers (so you need to use brackets).

2. All keys in JS are strings. If you try to index an object (arrays are objects) with a number, JS will first convert that to a string.

3. Arrays in JS are known as "exotic objects" and have special behavior -- if you try to set an own property (that is a property which belongs to that object and not its prototype) which also is an integer, it will set that property and then update the length value.

4. This special handling doesn't apply because 0.5 isn't an integer. You've just added the property '0.5' to the object. In effect you have created something like the following:

const items = {
   '0': 1,
   '1': 2,
   '2': 3,
   'length': 3,
   '0.5': 1
}

You could have called your additional property boobies and it would have the same effect, as long as it's not an integer when converted to a string and then converted back into a number.

Jump in the discussion.

No email address required.

K


Give me your money and I'll annoy people with it :space: https://i.rdrama.net/images/16965516366194396.webp

Jump in the discussion.

No email address required.

K

Jump in the discussion.

No email address required.

Most popular language in the world somehow.

Jump in the discussion.

No email address required.

It's not rocket science. It's the only thing you can run in a browser, browsers are where you do 70% of computing in 2023.

Web Assembly may change this with time, but JS is here to stay.


Follower of Christ :marseyandjesus: Tech lover, IT Admin, heckin pupper lover and occasionally troll. I hold back feelings or opinions, right or wrong because I dislike conflict.

Jump in the discussion.

No email address required.

No shit, what's baffling is that it wasn't replaced 20 years ago.

Jump in the discussion.

No email address required.

Replace it with what? Java applets were a security nightmare, so was Flash - ActiveX was dogshit too.

Completely ditching JS meant sites would no longer function.


Follower of Christ :marseyandjesus: Tech lover, IT Admin, heckin pupper lover and occasionally troll. I hold back feelings or opinions, right or wrong because I dislike conflict.

Jump in the discussion.

No email address required.

They managed to get rid of flash and java applets. You bite the pillow and get it done.

Jump in the discussion.

No email address required.

Flash was amazing and we should have double and tripled down on it

Jump in the discussion.

No email address required.

Webassembly is coming I guess :marseyshrug:

No DOM manipulation yet doe :marseyitsover:

Jump in the discussion.

No email address required.

There's always WebAssembly.

Jump in the discussion.

No email address required.

yes I mentioned that.

I think we need Web Assembly GC on all browsers for best support of all languages (WebKit will lag behind as usual) but that's shipping in Chrome and Fx nightly.


Follower of Christ :marseyandjesus: Tech lover, IT Admin, heckin pupper lover and occasionally troll. I hold back feelings or opinions, right or wrong because I dislike conflict.

Jump in the discussion.

No email address required.

js is great. It's not going to hold your peepee but it's a lot more intuitive than people like to pretend.

Jump in the discussion.

No email address required.

:marseyxdoubt:

Jump in the discussion.

No email address required.

Yeah I wouldn't trust anything I say.

Except for that.

And that.

Jump in the discussion.

No email address required.

js is great

get this hothead outta here :marseycop:

Jump in the discussion.

No email address required.

It's not even strongly typed

Jump in the discussion.

No email address required.

STRONGLY

TYPED

holy shit lol

Jump in the discussion.

No email address required.

Sorry I only work in languages where a good portion of my logic can be handled by the type system, imagine working in a language where you need to run your code to even know if it might work.

Jump in the discussion.

No email address required.

Good proof that most programmers are legitimately r-slurred.

Jump in the discussion.

No email address required.

Noooooo I need muh compooter to tell me not to be r-slurred and not to index lists by decimal numbers :soycry:

Jump in the discussion.

No email address required.

Oh nice, we got a real life cowboy here who never makes a typo and type safety just slows him down.

:marseybountyhunter:

Go back to Brokeback Mountain.

Jump in the discussion.

No email address required.

If I want to put an element between the one at index zero and the one at index 1, 0.5 is the obvious place to put it.

Jump in the discussion.

No email address required.

There are an uncountably infinite number of slots between 0.0 and 1.0, so it's basically free memory

Jump in the discussion.

No email address required.

Where else would I put it? Ordering is a post-facto judgement anyways. Index them all and let Allah sort them out

Jump in the discussion.

No email address required.

you start counting from 0

:therefore: items.length = 0, 1, 2, 3 = 3 :marseyshapiro!:

Jump in the discussion.

No email address required.

Here's the thing. You assigned a property called '0.5' to an object that happens to be an array, then asked for the count, which is 3. If you want to update an array like you said they're not the same thing. You can do the same logic with a function object, it's valid. :marseywholesometrans:

let func = function () {};
func['you'] = 1;
console.log(func.you); // 1
Jump in the discussion.

No email address required.

You assigned a property called 0.5 to an object that happens to be an array

You shouldn't be allowed to do that.

:marseyindignant:

Jump in the discussion.

No email address required.

coulda :marseysockpuppet: shoulda :drafts: woulda :marseywould:

Jump in the discussion.

No email address required.

arrays are objects you big dumb doofus

Jump in the discussion.

No email address required.

You're mad that arrays can have metadata, b-word? What are fricking you, a fricking baby, b-word?

Jump in the discussion.

No email address required.

no, I just like dramacoin :marseyjewish:

Jump in the discussion.

No email address required.

JavaScript is like a language where logic was patched in later.

Jump in the discussion.

No email address required.

i hate this so much

Jump in the discussion.

No email address required.

>I used an array selector with a non existant value that isn't an index and it added it as a property to the object?!?! Does any one else hate JavaScript

Lmao

Jump in the discussion.

No email address required.

untypedcels get the rope when they die and god sees what they've done


Give me your money and I'll annoy people with it :space: https://i.rdrama.net/images/16965516366194396.webp

Jump in the discussion.

No email address required.

I work in corporate development, coding in heck is going to be a breeze

Jump in the discussion.

No email address required.

>he doesn't know


Give me your money and I'll annoy people with it :space: https://i.rdrama.net/images/16965516366194396.webp

Jump in the discussion.

No email address required.

It's common for the victims of abuse to make apologies and excuses for their abuser

Jump in the discussion.

No email address required.

Where am I supposed to live? Grief, anger? Denial is way better frick you

Jump in the discussion.

No email address required.

ITT: Highly regarded JScels explain why this is technically possible as if there was a point to this thread other than laughing at their r-slurred abortion of a "language".

Jump in the discussion.

No email address required.

Javascript won't hold your hand you dumb little baby b-word. How about you put on your thinking cap, pull up your big boy pants, and actually learn how to code, hm?

Jump in the discussion.

No email address required.

Javascript won't hold your hand you dumb little baby b-word.

Favorite language of young girls like @HardIsLife. Front end development is definitely way more masculine than aerospace, finance, manufacturing, logistics.

Jump in the discussion.

No email address required.

!slots100

Jump in the discussion.

No email address required.

I don't want to meet the person too stupid to figure out statically typed programming languages, but that is somehow smart enough to jump through all the hoops created by dynamic typing.

:#marseyindignant:


:#marseydisintegrate: :!#marseyflamewar::space::!marseyagree:

Jump in the discussion.

No email address required.

I love JavaScript so much then one day I tried Typescript and it was like that time I discovered what a prostate orgasm was.

Jump in the discussion.

No email address required.

so that was the fricking day you became a fricking CUTE TWINK, b-word?

Jump in the discussion.

No email address required.

You're treating it as an array list and an object. this is your fault.


:#marseytwerking:

:marseycoin::marseycoin::marseycoin:
Jump in the discussion.

No email address required.

β–‘β–‘β–‘β–‘β–‘β–‘β–„β–„β–„β–‘β–‘β–„β–ˆβ–ˆβ–„
β–‘β–‘β–‘β–‘β–‘β–β–€β–ˆβ–€β–Œβ–‘β–‘β–‘β–‘β–€β–ˆβ–„
β–‘β–‘β–‘β–‘β–‘β–β–ˆβ–„β–ˆβ–Œβ–‘β–‘β–‘β–‘β–‘β–‘β–€β–ˆβ–„
β–‘β–‘β–‘β–‘β–‘β–‘β–€β–„β–€β–‘β–‘β–‘β–„β–„β–„β–„β–„β–€β–€
β–‘β–‘β–‘β–‘β–„β–„β–„β–ˆβ–ˆβ–€β–€β–€β–€
β–‘β–‘β–‘β–ˆβ–€β–„β–„β–„β–ˆβ–‘β–€β–€
β–‘β–‘β–‘β–Œβ–‘β–„β–„β–„β–β–Œβ–€β–€β–€
β–„β–‘β–β–‘β–‘β–‘β–„β–„β–‘β–ˆβ–‘β–€β–€U HAVE BEEN SPOOKED BY THE
β–€β–ˆβ–Œβ–‘β–‘β–‘β–„β–‘β–€β–ˆβ–€β–‘β–€
β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–„β–„β–β–Œβ–„β–„
β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–€β–ˆβ–ˆβ–ˆβ–€β–ˆβ–‘β–„
β–‘β–‘β–‘β–‘β–‘β–‘β–β–Œβ–€β–„β–€β–„β–€β–β–„SPOOKY SKELETON
β–‘β–‘β–‘β–‘β–‘β–‘β–β–€β–‘β–‘β–‘β–‘β–‘β–‘β–β–Œ
β–‘β–‘β–‘β–‘β–‘β–‘β–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–ˆ
β–‘β–‘β–‘β–‘β–‘β–β–Œβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–ˆ
β–‘β–‘β–‘β–‘β–‘β–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–β–ŒSEND THIS TO 7 PPL OR SKELETONS WILL EAT YOU
Jump in the discussion.

No email address required.

Link copied to clipboard
Action successful!
Error, please refresh the page and try again.