r/learnjavascript

About JavaScript Frameworks ...

I've only been using pure JavaScript so far and want to know more about these frameworks. Heard of stuff like React, Vue, Svelte, etc. but no clue what they are or do. Can someone explain to me their purpose and the main differences between the popular ones?

reddit.com
u/heapdroid — 4 days ago

A beginner-friendly breakdown of why [] == 0 is true in JavaScript (and when to use === instead)

I made a short lesson on JavaScript comparisons and wanted to share the main points here in case it helps anyone who is learning.

The one that surprises most beginners is that an empty form field can pass validation. "" == 0 is true, so if (quantity == 0) treats "nothing typed" as "zero items".

0 == false       // true
"" == 0          // true
[] == 0          // true
NaN === NaN      // false
"10" < "9"       // true (strings compare character by character)

The reason is that == converts the types before comparing, while === does not.

5 == "5"    // true
5 === "5"   // false

My rule for beginners is to use === by default. The one exception I use on purpose is x == null, which is true for both null and undefined.

The video goes through all of this with runnable examples, including null and undefined, the form field bug, string comparison and localeCompare.

https://youtu.be/iJJ1lJIM81A?si=LHW-Pa2Nu2ZCs969

I would be happy to answer questions if anything is unclear.

u/ITower__Education — 5 days ago

How do you learn to put a question in steps?

Hi everyone,

I'm trying to learn Javascript and the one problem that always seems to be hardest = putting a question into the steps required.

I've learned so far:

basics - if/else - loops - arrays (holy hell this was hard for me) - functions (would you believe it, it's even harder..!)
Now everything seems to be coming together but i'm really strugling to fit it into steps..

For example;

You have a number (999) and need to find out how many times each bill and coin (array with bills and coins put together) can fit into the number.

For a human this is easy, you just look at the number and notice that a certain amount can fit into it and you remember that.

But i cannot for the life of me convert this into steps that fit into code..

Everytime i have to look at the answer, and sometimes it clicks where i think omg that was easy - but other times i look and think whats happening here?

I feel like i'm too dumb to understand the basics for what (from what i seem to understand) is the easiest of code-language..

If i put in my assignment i have a test but i'm affraid that i will hit a wall with the question again.

One thing i'm doing is writing every excersise on a notepad and if i feel like i need to explain something i just write it under in hopes that if i ever need that step again i'll know why i did it..

Is there some sort of skill that i'm missing, do i just not understand the basics enough, or am i just not smart enough?

Any help is appreciated!

btw; sorry for any grammatical errors, english is not my native language..

reddit.com
u/Majestic-Two7750 — 5 days ago

Beginner at JS

Can y'all recommend me the beginner topic of js? I rlly wanna do adv study just in case I can't comprehend it that fast.

Maybe even yt or web smth

reddit.com
u/ReadingReLemon — 4 days ago

what should i build as my first JavaScript project?

i know the basics of HTML and CSS and have just started learning JavaScript. I’m looking for a small and beginner-friendly project that can help me practice.

I'd love to hear some project ideas

reddit.com
u/hotburger_ — 7 days ago

What could I do with my javascript knowledge as a new student?

I've had prior coding experience in middle school with html using code.org and I have an ap computer science class in my junior year of highschool learning javascript. As the title states, what are some things I could do in the future?

u/VoidedX — 6 days ago

How to push values onto an array using random() and for() loop.

I will explain now in more detail. I am currently using the Khan Academy Javascript course to learn the basics of Javascript. I have been struggling with this specific project so much, so don't mind the exstensive comments.

//Controls the X and Y Positions of the raindrops.

var xPositions = [200];

var yPositions = [0];

//This for loop uses a random function to add more values to the X and Y positions. This will create more raindrops.

//Draw Function to animate.

draw = function() {

background(204, 247, 255);

//This for loop draws the raindrops based on the X and Y arrays above.

for (var i = 0; i < xPositions.length; i++) {

//Color + Decorations of the raindrops.

noStroke();

fill(0, 200, 255);

//Draws a circle at the X position and Y Position based on the cyclic increases of the variable i. Y position will then drop by a rate of 5 to make the rain fall to the ground.

ellipse(xPositions[i], yPositions[i]%400, 10, 10);

yPositions[i] += 5;

}

};

As you can see, there is a comment that describes the for loop using a random function to push values to the xPositions and yPositions arrays, which in turn will allow me to create more raindrops. My question is how can I do this? I've been experimenting typing different things, but it seems that the for loop just keeps crashing my computer. I know this is a very simple question but I am still on the basics.

reddit.com
u/DapperBumblebee22 — 14 days ago

What is DOM element recycling??

Hi everyone, I'm learning React Virtuoso and came across the term "DOM element recycling." I understand the basic idea of DOM elements, but how can they be "recycled"? Could someone explain it in simple terms? 🤔

reddit.com
u/Neat_Living_6765 — 14 days ago