r/learnprogramming • • Apr 05 '22

Name one programming/comp sci concept you never understood and if you understand it, try to explain it to them

Name a programming concept such as virtual functions, pointers, certain algorithms, etc that you always had a hard time understanding and why.

Someone else who reads yours and does understand it, try to explain it to them to help them learn

1.6k Upvotes

738 comments sorted by

View all comments

23

u/Sakin101 Apr 05 '22

Javascript

14

u/TangerineX Apr 05 '22 edited Apr 05 '22

I think people take Javascript to be way more complicated than it needs to be. In javascript, there's really 4 things to think about

  1. "primitives", or various values. These are strings, numbers, and booleans

  2. Arrays, which are just an ordered list of things

  3. Objects, which is a map of key: value pairs, which are all primatives.

  4. Functions, which take some input, and turn it into something else

Basically EVERYTHING in javascript is built off of these concepts. If you understand these, you've understood 90% of javascript.

Surprisingly, I've learned more about Javascript by learning Typescript instead, which gives a more opinionated way of using Javascript in a way that makes a bit more sense. It's also become the standard for writing stuff in many frameworks, such as Angular and React.

1

u/__Fred Apr 06 '22

Can you explain the "prototype" property?

If I want to access a property on an object and JS can't find it, it looks inside the prototype, right? No... https://www.w3schools.com/js/js_object_prototypes.asp I used to understand this. It feels like the most complicated part of JS but you don't need it in TypeScript.

Okay... JS builds up OOP out of dictionaries and it needs "prototype" for that. Maybe it would be useful to see how one would go about doing that to Python?

→ More replies (1)