256 Kilobytes

JavaScript is gay

Articles in Computer Programming | By Huevos Rancheros

Published | Last Update

277 views, 1 RAM, and 2 comments

And this is why

var person = {
 hair: "tunescool",
 eyes: true,
 height: "Avg",
 tattoos: "I'm Joe Biden's husband, Joe Biden"
}

var personCopy = person

delete personCopy["eyes"]

console.log(person)

What do you think it will print?

If you said the below, you're correct:

{hair: "tunescool", height: "Avg", tattoos: "I'm Joe Biden's husband, Joe Biden"}

Something about personCopy only being a reference to the person object. So you're actually modyfying the person object.

So, even if you pass personCopy to a new module (file) in NodeJS, it will still edit the original which is now fuck knows where and your shit will bug.

The correct way to do it is probably this:

var personCopy = JSON.parse(JSON.stringify(person));

GAY

Users Who Have Downloaded More RAM:
Hash Brown (2 months ago)
🐏 ⨉ 1
Posted by Huevos Rancheros 3 months ago

Edit History

• [2020-08-31 13:33 PDT] Huevos Rancheros (3 months ago)
• [2020-08-31 13:33 PDT] Huevos Rancheros (3 months ago)
• [2020-08-31 13:33 PDT] Huevos Rancheros (3 months ago)
• [2020-08-31 13:33 PDT] Huevos Rancheros (3 months ago)
• [2020-08-31 13:33 PDT] Huevos Rancheros (3 months ago)
• [2020-08-31 13:33 PDT] Huevos Rancheros (3 months ago)
• [2020-08-31 13:33 PDT] Huevos Rancheros (3 months ago)
• [2020-08-31 13:33 PDT] Huevos Rancheros (3 months ago)
• [2020-08-31 13:33 PDT] Huevos Rancheros (3 months ago)
🕓 Posted at 31 August, 2020 13:33 PM PDT

Read More:
JavaScript
Js
gay
Profile Photo - Huevos RancherosHuevos RancherosStaff

I sell rare words

Profile Photo - August R. GarciaAugust R. GarciaLARPing as a Sysadmi...Portland, ORSite Owner

Interesting.

Also:  https://stackoverflow.com/questions/518000/is-javascript-a-pass-by-reference-or-pass-by-value-language

Users Who Have Downloaded More RAM:
Huevos Rancheros (3 months ago)
🐏 ⨉ 1
Posted by August R. Garcia 3 months ago 🕓 Posted at 01 September, 2020 17:28 PM PDT

Sir, I can do you a nice SEO.

Profile Photo - Hash BrownHash BrownInternet ActivistEnglandStaff

If you like Javascript, you are wrong.

Download more RAM. 🐏 ⨉ 0Posted by Hash Brown 3 months ago 🕓 Posted at 03 September, 2020 03:35 AM PDT

"THAT DOG IS GETTING RAPED" - Terry A. Davis

Post a New Comment

Do you like having a good time?

Register an Account

You can also login to an existing account or reset your password. All use of this site is subject to the terms of service and privacy policy.

Read Quality Articles

Read some quality articles. If you can manage to not get banned for like five minutes, you can even post your own articles.

View Articles →

Argue with People on the Internet

Use your account to explain why people are wrong on the Internet forum.

View Forum →

Vandalize the Wiki

Or don't. I'm not your dad.

View Wiki →

Ask and/or Answer Questions

If someone asks a terrible question, post a LMGTFY link.

View Answers →

Make Some Money

Hire freelancers and/or advertise your goods and/or services. Hire people directly. We're not a middleman or your dad. Manage your own business transactions.

Register an Account