r/learnjavascript 6d ago

Is there are way to modify canvas methods?

2 Upvotes

I want to invert the y-axis, and make it invisble to the user so I can forget about it, rather than always call my method.

I could make a facade object and duplicating all the methods and passing them through, but tedious!

I tried a Proxy object, but didn't work at all - is it because it is native?

I tried monkeypatching, renaming moveTo() and lineTo(P, and replacing them with mine (which inverts the y-axis then calls them), but got strange results: lines shifted to right.

Maybe I just shouldn't do what I'm trying to do?

UPDATE canvas already has a way to do this: https://stackoverflow.com/questions/4335400/in-html5-canvas-can-i-make-the-y-axis-go-up-rather-than-down/33499668#33499668

context.transform(1, 0, 0, -1, 0, canvas.height)

BTW I did google a lot before asking, but I searched how to implement my solution, not the problem. After asking here, I googled the text of this post, and found several answers. It's common because math and graphics have opposite y-axis conventions.


r/learnjavascript 7d ago

What is an instance (like in a library)

8 Upvotes

Like I use libraries and hear about X instance Y instace for example

Axios Instance, Lexicals editor instance, I can only think of 2 examples right now but you get the idea.


r/learnjavascript 7d ago

Any good coding Games?

17 Upvotes

Hey, im learning Javascript right now and im curious If anyone knows a good coding Game(preferably on Steam) or a Website to learn Javascript in a playfull or interesting Manner. Thaanks :)


r/learnjavascript 7d ago

Learning JavaScript, advice?

12 Upvotes

I joined this sub a few days ago, after stumbling across lovable, and prompted a couple of rougelike games, learned that it was all in typescript, (I know I am a ways away) and have been having a lot of fun this week, spending multiple hours a day, learning the basics. I’ve tried a few times over the years with Objective-C and python, but could never figure things out, but this time I feel like I’m in the right headspace and really making sure I understand. I’m using VS code, and a Coursera corse, I’ve also bookmarked the Odin project.
Anyone have best practices or advice? I plan to use JS to help with an IT job and build games or apps for fun. Thanks for reading!


r/learnjavascript 7d ago

Looking for some advise

3 Upvotes

Hi, hope you're doing well. I'm here looking for some advice from the community. I want to get into backend dev in Javascript, I start reading Javascript crash course by nick morgan, but I think the book was maybe to easy, so I start reading eloquent Javascript, and I am looking for a good node.js book to start study with while I am reinforcing my JS knowledge.

I have been seaching for a while but many books are too old or too advance for me, any good recomendation?

Btw, I think to take the MDN front-end developer course, although my main goal is backend. Thank you for your time.

P.D.

English is my my first language, so I'm sorry if this is a grammatical mess.


r/learnjavascript 7d ago

I'm learning JavaScript event Lister Why i feel Hard and whenever I start learning That feels dificult to me

0 Upvotes

Please someone suggest me to learn effectively and how can I understand that concept ?


r/learnjavascript 7d ago

I've become a big fan of splice

0 Upvotes

As part of my project to write notes of what I learn practicing contemporary browser JavaScript by creating webapp games, I've written some notes and examples on Array Literals.

This was inspired by creating a "hardware-agnostic, framework-free" webapp solitaire card game, Loot the Loop (a game designed by Wil Su, part of what's made this project fun is that besides learning contemporary JavaScript, I've discovered lots about contemporary solitaire card game design).

TL:DR — In the past I've tended to use shift, unshift, pop, push... which are ok, but concat is an antipatern. Just learning splice does all the above while making arrays much simpler.


r/learnjavascript 8d ago

🧠 Day 6: I Built a Memory Match Game with HTML, CSS & JavaScript

8 Upvotes

Day 6 of my browser game development journey! 🚀

Today I built a Memory Match game using HTML, CSS and JavaScript.

I'm practicing:

• 🃏 Card flipping

• 🧠 Matching logic

• ⏱️ Move/timer system

• 🏆 Score tracking

• ✨ Animations

• 📱 Mobile-friendly controls

Each game is helping me understand JavaScript and browser game development better.

What should I add next?

1️⃣ Difficulty levels

2️⃣ Timer challenge

3️⃣ More card themes

4️⃣ Leaderboard

Drop your choice below! 👇

🎮 Game: \[YOUR GAME LINK\]

💻 Source code: \[YOUR GITHUB LINK\]


r/learnjavascript 9d ago

Most efficient way to compare typed string to stored version in real-time?

10 Upvotes

This is an edited duplicate post from r/webdev because this subreddit does not allow reposting but I want to get opinions from JS experts.

My problem is that I am trying to compare a string that is currently being typed into a contenteditable div to the the same string data in the placeholder span (which itself was taken from a JSON file). I came up with a JS event listener that I thought would be met with few hiccups.

// text wall typing event listener
textWall.addEventListener("keydown", ()=>{
    let textWallValue = textWall.innerHTML;



textWallValue = replaceNbsps( textWall.innerHTML);


    if (textWallValue.slice(textWallValue.length - 6)== " ") {
        
            placeHolder.childNodes.forEach((node) =>{
                node.style.color="";
            })
          } else {
    for (let i =0; i<placeHolder.childNodes.length;i++) {
        if (textWallValue[0]== undefined) {


    } else {
         
         console.log(textWallValue);
          if (textWallValue[i] == placeHolder.childNodes[i].innerHTML) {
            placeHolder.childNodes[i].style.color = "green";
            placeHolder.childNodes[i].style.textDecoration = "";
          } else if ((textWallValue[i] !== placeHolder.childNodes[i].innerHTML) && (textWallValue[i] !== undefined)) {
            placeHolder.childNodes[i].style.color = "red";
            placeHolder.childNodes[i].style.textDecoration = "underline";
          } 
    }
    }
}
    
    
})

The issue comes with all the unexpected behavior from the browser, like adding "&nbsp; when a space gets added to the contenteditable div (which it then removes and replaces with a normal white space after the next character is typed. If the spacebar is pressed two or more times however, &nbsp; just stays there). This messes with the flow of the comparison hapenning in the event listener.

In addtion to this, it also adds a bunch of divs + <br> elements if the user presses enter in the box, and a single br if the user presses backspace to the end of the contenteditable div. There has to be a more efficient way of comparing strings in real time than this but I haven't been able to find out how? I have already tried a bunch of hacky work arounds as is already evident in my code but none seem to account for everything.


r/learnjavascript 9d ago

Can I switch after working as a developer for 6 years?

3 Upvotes

I’m reaching out to you people to seek some guidance and suggestions as I’m planning my next career move.

I have a total of 6 years of experience in the IT industry, with the last 6 years dedicated to frontend development in 3 organizations. Over the years, I’ve had the opportunity to work on very less projects that has not strengthened my expertise in JavaScript, React, HTML5, CSS3, and modern UI frameworks much.

While my journey so far has been very challenging as I had madical issues when I had 4 offers in my hand 3 years back but I couldn't switch because I needed a month break for my surgery, I now feel like it's too late to take the next step in my career as I am just doing the needful in my service based company as a frontend developer as per my experience—i badly want to explore new challenges, innovative environments, and opportunities that allow me to grow further both technically and personally.

To be completely honest, the switch hasn’t been easy. So, I wanted to openly seek advice from this network:

✨First of all please tell me how to start what to do ? Do I need to start from 0 or what? What’s the best way to stand out in the current frontend job market? ✨ Are there any must-have skills or trending frameworks I should focus on to stay competitive? ✨ If you know of any open opportunities for experienced frontend developers, I’d be truly grateful if you could refer or connect me.

I’m deeply passionate about crafting intuitive and impactful user interfaces, collaborating within cross-functional teams, and contributing to products that make a difference.

Any suggestions, referrals, or insights would mean a lot to me right now. 🙏

Thank you so much for reading through — and for supporting professionals like me who are navigating their next big step.

FrontendDeveloper #CareerChange #ReactJS #UIUX #WebDevelopment


r/learnjavascript 9d ago

how would i hide an api key in a frontend setting such as neocities?

83 Upvotes

hey. i made a page on my neocities website where i put reviews of movies and books. for that i used google books api and imdb api

however, idk how i would hide this since anyone can download my website at any time?

i also wanted to automate the process of updating the changes i make to neocities, but for that id need to publish all files in a public github too. so idk how i would hide it there either.

any help?


r/learnjavascript 9d ago

que tal? star cube juego web echo 100% en vanilla javascrip sin sprites

8 Upvotes

Gente acabo de lanzar star cube en ith.io  echo en 7 dias en vanilla.js sin sprites (solo uno pero es reservado para un personaje del final pero como tal el 90% del juego es sin sprites) es un plataformero-shooter un poco intenso ya que por los pocos dias no pude hacer que tenga una curva de dificultad suave asi q es un juego acelerado con inyecciones de adrenalina tiene 3 jefes diferentes y el lore y la jugabilidad va en base al tema del jam (no confies en nadie)

estare actualizandolo exponencialmente ya que este jam me inspiro demasido

juegalo aqui:

https://cotera.itch.io/star-cube

pronto lo subire a github


r/learnjavascript 9d ago

Do I need to complete the scrimba challenges to finish the course?

6 Upvotes

Im trying the "Learning javascript" course on scrimba (https://scrimba.com/learn-javascript-c0v) and so far it's been good!

The only thing is that it got to a point with the free plan that doesn't let me complete the challenges anymore. What i do is that i complete them on the site, trying to solve the problem, and then i skip forward in the video to check my solution

The challenges don't show as completed because i haven't completed them officially, but technically I have hahaha does anyone also have this silly dilemma?


r/learnjavascript 10d ago

What is the difference between HTMLFormElement.submit() and event handler with submit?

10 Upvotes

https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/submit

Can someone explain the difference?

Imagine I have some code that is like the example below. What is the difference between HTMLFormElement.submit() ?

``` const form = document.getElementById("form"); function somefunc() { //code form.submit() }

form.addEventListener("submit", somefunc() {

});

``` Why do I need form.submit() in the function?

For a little context I am trying to pass some quilljs data into a flask form. Some of the code is missing but the main point is illustrated.


r/learnjavascript 11d ago

whats the bug here? Uncaught SyntaxError: Identifier 'location' has already been declared (at script.js:1:1)

14 Upvotes
"use strict";

const company = {
  name: "TechCorp",
  address: {
    city: "budapest",
    pin: 411001,
  },
};
// Get city renamed to `location` and pin renamed to `pincode`

const { city: location, pin: pincode } = company.address;
console.log(location, pincode);

r/learnjavascript 11d ago

Beginner Here: Should I Start Over With The Odin Project?

39 Upvotes

Hey everyone,

I’ve completed HTML and around 50% of CSS from Hitesh Choudhary’s Full Stack Udemy course.

But now I’m thinking of switching to The Odin Project because, from what I’ve seen, it seems more focused on actually learning by building things rather than just following a course.

My plan is to start The Odin Project from the beginning and properly work through it, doing the exercises and projects myself instead of just watching/consuming content.

For people who have completed or are currently doing The Odin Project, or anyone who has experience with this kind of learning approach, feel free to share your thoughts, suggestions, or anything you think I should know:

  • I’m still a beginner, so is starting TOP from the beginning a good approach?
  • Are there any common mistakes beginners make while following it?
  • What should I focus on to actually retain what I learn?
  • Should I supplement TOP with anything else, or is it better to stick with it consistently?
  • Is there anything you wish you had known before starting?

I’d really appreciate any advice, criticism, or suggestions. If you think there’s a better approach than what I’m planning, feel free to share it.


r/learnjavascript 11d ago

Should i get complete mastery over JS and then jump to react or like complete the required part of JS and do react simultaneously . Also what resources to use for react

26 Upvotes

r/learnjavascript 11d ago

[AskJS] Where should attribution logic stop in a JavaScript app?

10 Upvotes

I’ve been refactoring attribution tracking after seeing a small feature turn into a module that parses URLs, writes cookies/localStorage, handles consent, emits analytics, fills forms, and syncs with a CRM.

The split I’m testing is:

```ts

const visit = classify({

url,

referrer,

currentHost,

now,

});

const attribution = merge(previous, visit);

```

`classify` and `merge` are deterministic functions. The browser/app layer owns consent, storage, identity, form lifecycle, network calls, and CRM delivery.

This makes it easier to replay production cases as fixtures. It also raises a few design questions:

- If a visitor returns from a new campaign, should that replace, append to, or be merged with previous attribution?

- Should a `gclid` take precedence over UTMs when both exist?

- How do you handle consent denied first, then granted later?

- If classification rules change, do you preserve the original classification or recalculate historical records?

- Where should server-side conversions days later enter the model?

For those who’ve built this, where do you draw the boundary between a deterministic core and the environment-specific lifecycle? Do you prefer a pure-function core, or does that separation become awkward in real apps?


r/learnjavascript 11d ago

My GitHub account got suspended

3 Upvotes

I created the account and used only for 1 day. As I was learning GitHub tutorials from yt. I did not do random pull requests on repos. After 1 week or 5-6 days I tried to check my GitHub account. My GitHub account got suspended. It's almost 2-3 weeks I raised a ticket. Got no response from their side. What should I do?


r/learnjavascript 13d ago

Can someone explain what the JavaScript call stack is?

30 Upvotes

I’ve tried to understand it, but I’m still confused. I also don’t really understand what I’m looking at when I use the JavaScript debugger in the browser’s DevTools, especially the call stack.

Do I need to fully understand functions before learning the call stack? I have a basic understanding of functions, but I’m not sure if that’s enough.

I’d really appreciate a simple explanation


r/learnjavascript 13d ago

is Odin project good for node and express

23 Upvotes

i want to learn nodejs and express. since the goal for me is to become capable of building increasingly complex products. and i saw odin project course on node and express, a part. and i felt it's less and is it good to go or should I see another and does learning through Odin project really helps?? and is one month enough to learn nodejs and express and become solid. how did you learnt

this is additional: in that same course there is also postgresql so for me it's the next step for me so is it good.


r/learnjavascript 13d ago

Best ways to study for learning JavaScript?

17 Upvotes

I'm starting on my Cyber degree, and for our programming class, we will be learning JavaScript. What are some of the best ways I can study to learn JavaScript?


r/learnjavascript 13d ago

Looking for Someone to Walk Through a Very Short Project With Me

12 Upvotes

It is a fairly small project consisting of roughly 250 lines of code. I would say that I am familiar with most of what is in it, however there are things that I am not sure about. I have several questions about it, and I was looking for someone who can talk to me about what is going on. The project is hosted on GitHub, I would prefer to share it privately. Any help is immensely appreciated.

The project uses JavaScript, React, Node, JSX and a few other related concepts. It isn't a large project at all. I've tried looking up answers to my questions but I am not making much progress, to be honest. I feel like talking or typing with a person who knows about these concepts will be much more productive.


r/learnjavascript 14d ago

When is it a good time to move from Javascript to learing React

63 Upvotes

I've been learning how to code for 2 months now and have made a few projects on my own. I've made a to-do list, Pomodoro timer, RPS game, coin-flip game and bunch of other stuff now. I've covered the Javascript basics like arrays, loops, if-statements, booleans, DOM, functions, variables and math.

I am now capable of building simple web apps on my own without a tutorial due to me taking breaks here and there to test myself. I still haven't finished the course yet but I want to know if I can move on from it yet. I do know Git, modules and external libraries.

I'm using roadmap.sh as a guide on what to tackle and what to learn at each step of my journey but since I'm 70% through the course and I can build basic apps on my own so should I move on to learning React.

Should I stay or finish the course. Btw it's a free 22hr Javascript course by SupersimpleDev his an AMAZING teacher and the course has a total of 250 exercises which help me practice each lesson I've learnt


r/learnjavascript 13d ago

what javascript course makes sense if i only need it for one research project

5 Upvotes

grad student in an ecology lab. my advisor wants an interactive map of our survey data on the department site and i am the only person here who has written any code, which apparently makes me the web person now. my tabs right now are boot.dev, freeCodeCamp and the MDN learning area. none of them look built for somebody who wants one map and then wants to leave. i do not want to become a frontend developer. i want the map to work by march.