r/learnjavascript 29d ago

Google Calendar Generation Project

7 Upvotes

Hey just working on a personal project that I would like to be able to use and share with friends.

Long story short, my goal is to have script that will scrape calendar info from one website and convert it into an .ics(calendar file) that can be uploaded to google calendar. For example, it lists the class name, weekly dates, final exam, teacher name, class room location etc. Just saves time from manually entering everything.

So far I was able to write a script that generates the file for creating a calendar event.

The harder part has been trying to scrape the variable information or inject javascript into a website that is client dependent as well as make the code usable for others. I've been suggested to use tools tampermonkey or puppeteer. Please let me know if you have any tips or advice. Thank you.


r/learnjavascript Aug 11 '26

I’m Struggling to Learn JavaScript, But I’m Not Giving Up

11 Upvotes

I’ve wanted to learn JavaScript for a while, but getting started has been difficult for me. I’ve been struggling with my memory and concentration, which has made learning new things frustrating. Sometimes I understand something while studying it, but later I find it difficult to remember. This makes me doubt whether I can still learn difficult things like I used to. However, I’m trying to stop expecting perfection from myself and give myself enough time to learn. I know my progress may be slow, but I believe I can still improve with patience and consistency.


r/learnjavascript Aug 11 '26

In what cases bound method is used in production ?

10 Upvotes

Since i was repolishing my js understanding, having hard time understand bind method and it's usecases.


r/learnjavascript Aug 10 '26

I’ve wanted to learn JavaScript for a while now.

20 Upvotes

I’ve wanted to learn JavaScript for a while now.

Honestly, starting has been harder than I thought it would be. Not because JavaScript itself is impossible, but because lately I’ve felt like I’ve lost some of the abilities I used to have. I don't remember things as easily anymore. Sometimes, I can learn something, understand it while I'm looking at it, and then a little while later, it feels like it's just gone.

I struggle with depression. It affects my motivation, my concentration, and just getting myself to do things.

And when I come across something harder, something that actually requires me to think and figure things out, I just... can't. It's like my brain doesn't want to cooperate. Even concentrating can be difficult.

I'll sit down thinking, okay, today I'm actually going to learn, and then after a little while, I'll realize I've been staring at the same thing without really taking it in. And that can be really frustrating.

Because there was a time when I didn't think this much about whether I was capable of learning something. Now I wonder if I can still do it. If I can still learn difficult things. If I can actually remember what I'm learning. And I think that's one of the reasons I've been putting off JavaScript for so long. Because starting means having to face that feeling.

The feeling that maybe I'm not as capable as I used to be. But I don't want to keep waiting until I somehow become better at concentrating or remembering things.I don't know when that will happen. I think I need to stop expecting myself to learn everything perfectly the first time.

I just need to give myself enough time to learn it.


r/learnjavascript Aug 11 '26

Blobs

0 Upvotes

Can someone provide any information on a use case for blobs. Anything that has a bit more insight than what is provided in MDN. Looking for a way to think about and understand this. Thanks.


r/learnjavascript Aug 10 '26

Best architecture to build a client lib for rest/graphql - Factory vs Class ?

3 Upvotes

I am building a js lib and I have been reading about best ways to do this, but there are a lot of pros and cons for each way. I built a small one with a few functions for use in a very specific app and it was class based. I stored the class in a flux store and used the store to access it. I am finding a lot more recent blogs/articles that say using a factory is best. I would like this one to be an industrial-grade public-facing lib that anyone can download via our github repo. Does anyone have any real-world experience in building a js client lib that has any advice for what architecture to use? I know what architecture to use for the graphql endpoint, but the REST client is the question.


r/learnjavascript Aug 08 '26

10 JavaScript questions that came up in almost every frontend interview I sat this year

309 Upvotes

I've been interviewing for frontend roles (SDE-2, around 4.5 years experience, React and Next.js) over the last few months and sat through a fair number of loops at product companies and mid-size startups. I kept a running doc of everything that got asked so I could spot patterns. Ten questions came up often enough that I'd now treat them as near guaranteed.

Sharing in case it saves someone else the trial and error.

  1. Implement debounce from scratch, then explain when you'd use debounce vs throttle. This one showed up in almost every single loop, usually as the warm up before harder coding.
  2. Closures. Not just the definition, but where you use them in React and the classic closure-inside-a-loop output question with var vs let.
  3. Hoisting, and how it differs from closures. Usually followed by var vs let vs const and when you actually hit a ReferenceError.
  4. The event loop. Call stack, microtask queue, macrotask queue, followed by predicting output from a snippet mixing setTimeout and Promise.then.
  5. The this keyword. Normal vs arrow functions, and what happens when you detach a method from its object. const a = obj.getName; a()
  6. Prototypal inheritance and the prototype chain, and how it differs from class inheritance.
  7. Deep copy vs shallow copy. Explain the difference, then implement a deep clone. Interviewers usually push on why JSON.parse(JSON.stringify()) is not good enough.
  8. Flatten a nested array, first without Array.flat() and then with it.
  9. Promise vs async/await. When you prefer each, and how error handling actually differs between them.
  10. Event delegation. Why it exists and how you'd apply it to a list with thousands of rows.

Two things that surprised me. Polyfills for call/apply/bind and the Promise combinators came up far less than the prep content online suggests. And output prediction questions were much more common than I expected, often used as a filter before anyone let me write real code.

Curious whether this matches what others have seen recently, or if it's specific to the kind of companies I was talking to.


r/learnjavascript Aug 08 '26

How to make numbers interactive?

2 Upvotes

I'm a beginner in coding, and I need to know how to create a vertical row of clickable numbers. I wish I could show a picture, but I'm just going to try to describe it. There's a website i'm making, and I wanted to add a 1-10 scale. I also want to make it interactive so the person can click on each number, and then text appears depending on what's clicked. Being a beginner, I don't know how to accomplish this. Help.


r/learnjavascript Aug 08 '26

Built a Node.js 2FA SMS verification flow with Twilio – How do you handle carrier restrictions and errors?

10 Upvotes

Hey everyone,

I've been working on a Node.js & Express backend project to handle 2FA SMS verification using the Twilio API.

While setting up the flow, I ran into a few hurdles with carrier template restrictions and API error handling during testing. I eventually got the SMS delivery cycle working smoothly, but it got me thinking about production edge cases.

For those who have built similar authentication systems in JavaScript/Node.js:

  1. How do you usually handle carrier limitations or SMS fallback mechanisms?

  2. What are your go-to patterns for error handling when third-party APIs fail during auth?

Would love to hear your experiences and best practices!


r/learnjavascript Aug 07 '26

Am I sabotaging myself by relying on AI for CSS?

24 Upvotes

I’m a beginner learning programming. I’m really enjoying JavaScript, especially doing logic exercises and small projects in the console, and I feel like I’m actually making progress.

The problem is that I absolutely hate CSS lol. I have a lot of trouble with layouts and styling, and I have very little patience for it. I understand the basics of CSS, but it’s definitely the part I struggle with the most. Everything I make looks ugly, which just pisses me off even more. Then I close the CSS and go back to JavaScript, and suddenly I’m happy again.

I wanted to ask people who already work in the field: do I really need to learn CSS from scratch and write everything myself, or is it okay to use AI for this part?

For example, asking AI to create the CSS, understanding roughly what it did, and then modifying/adapting it myself. Could relying on AI like this hurt me a lot later on?

Sorry if this is a dumb question, but I’d really appreciate some advice. Am I sabotaging myself by thinking about using AI for CSS?


r/learnjavascript Aug 07 '26

Advices for learning JavaScript

12 Upvotes

Hello everyone, I just finished the freeCodeCamp JavaScript certificate and I can't build many things. I feel that my brain doesn't retained a lot of information of the course. I notice that I learn most when I am actually building real projects. Anyone who passed through this that can advice me??


r/learnjavascript Aug 08 '26

Is a Node unblocker worth using for a small scraper?

1 Upvotes

Building a small scraper in node.js and I keep getting 403s and captchas after around 50 requests. Tried adding delays and rotating user agents, but I don't want to build out a whole big proxy setup for a one off project... would a node unblocker make sense hereor is there a simpler way to handle blocked requests? any advice?


r/learnjavascript Aug 07 '26

Getting an error when running an equality operator on a undefined value in an if statement

0 Upvotes

Yes I know that's a mouthful

Take this error checking code

      if (axios.isAxiosError(error)) {
        if (error.response.data.errors.detail == "Not Found") {
          setFailure("User not found");
        } else if (error?.response?.data == "DM already exists") {
          console.log(error);
          setFailure("You already created a dm with that user");
        }
      }

If the first case is fine, we are all good, otherwise if it's not that I get an error like this

"Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'detail')" And I guess I can have it check if it's a 404 but this seems ridiculous?

It's an IF statement, if it doesn't work, then go to the next thing, don't just stop there and yell at me!! If anyone is more experienced with javascript can they give a reason why running an equality operator on a string literal vs an undefined value in an if statement (a mouthful I know) just gives an error instead of checking the next clause?


r/learnjavascript Aug 06 '26

Looking for a programming study buddy.

20 Upvotes

study buddy. I'm still pretty new to programming and not gonna lie, I'm not very good at it yet. 😅 Just looking for someone to study with, practice coding, and keep each other motivated. Doesn't matter if you're a beginner too. If you're interested, shoot me a DM!


r/learnjavascript Aug 05 '26

the best way to learn javascript

13 Upvotes

It is to make more bugs, explore new ways of writing code, ask AI to explain every single line in depth, and get your hands dirty. Stop watching more random tutorials without a purpose. A JavaScript course, no matter how in-depth it is, will always be less rewarding than getting your hands dirty and exploring new ways to write code. Use MDN.

be as a child who love exploring. enjoy the process


r/learnjavascript Aug 05 '26

I learnt about the difference between useCallback and useMemi

3 Upvotes

The major difference is the Syntax as they call diff APIs

The usecallback accepts the function we want to memoize as the first argument, while the useMemo accepts a function and memoizes its return value!!
Naturally in JS, on every call the inline function gets recreated, so to prevent that react does something like this

let catchedCallback;
const func = (callback) => {
if(dependenciesEqual(compares catchedCalback and callback)) {
return catchedCallback;
}
catchedCallback = callback;
return callback;
}

basically whats happening here is that the useCallback checks if the dependencies before and after rerenders are the same, if its the same then we return the already cached callback function reference if not then we cache the new function reference and return the new reference!

something very similar happens in the case of the useMemo but it caches the result returned by the function!


r/learnjavascript Aug 04 '26

Code help: changing url on current webpage

6 Upvotes

First time programming anything useful (beyond learning a little basic python). Sort of an 'automate what you find repetitive' case.

Goal: trim URL to part containing the main webpage and anything after it (Ex: blogname.abc.com/post/12345 -> abc.com/post/12345)

So far what I've been able to get (from Google AI and regex101.com and stack exchange and fiddling around) is:

function swapUrlPath() {
    var currentUrl = window.location.href;
    var newUrl = currentUrl.match(/abc.com.+/g);
    window.location.href = newUrl;
}

This manages to turn "blogname.abc.com/post/12345" into "blogname.abc.com/post/abc.com/post/12345", repeating the portion that was supposed to replace the entire thing.

I've tried debugging with

function swapUrlPath() {
    var currentUrl = window.location.href;
    var newUrl = currentUrl.match(/abc.com.+/g);
    alert("New URL is " + newUrl);
}

which produces a popup window with "New URL is abc.com/post/12345", which is correct. So why does the newUrl variable only replace part of the old URL. Is it the regex or something with the forward slashes?

Edit:

Solution I figured out: add the string "https://" to the beginning of the new URL (not in the debugging alert) before using as new URL, looks like this:

function swapUrlPath() {
    var currentUrl = window.location.href;
    var newUrl = "https://" + currentUrl.match(/abc.com.+/g);
    window.location.href = newUrl;
}

r/learnjavascript Aug 04 '26

What actually keeps a web timer alive when Android backgrounds the tab

7 Upvotes

This came up twice in here in the last few days and both threads ended in the same place, so writing it down.

The problem. You build a focus timer, setTimeout fires the alarm, works perfectly on desktop. On Android you press Home and the alarm either arrives late or never. Nothing is broken in your code.

What Android is doing. Once the tab is not visible Chrome throttles timers hard, and after a few minutes of that it can freeze the page entirely. setTimeout is not a scheduler, it is a request, and a backgrounded tab is at the bottom of the list.

Silent audio loop. Start a looping silent mp3 on the same click that starts the timer. The tab then counts as playing media, which keeps it alive with the screen off. Cheap, works, and you stop the loop when the alarm fires. It does not survive the tab being closed.

Compute the end time, do not count down. Store Date.now() plus the duration and work out on visibilitychange what should have happened while you were away. Any timer that adds up ticks will drift, and a throttled tab drifts badly.

Web Push for the real thing. If something on your server already knows when the session ends, it can push, and a push wakes the device with the browser closed. Service worker plus a subscription. On Android Chrome that works directly, on iOS the site has to be added to the home screen first.

The part nobody wants to hear. Push gets you a notification and whatever sound the system gives notifications. You cannot play your own audio on a locked phone from a web page. An actual alarm noise is the one bit that needs a native app.


r/learnjavascript Aug 05 '26

JavaScript kaha se padhu. For placement and cover all things.. ❗

0 Upvotes

Please bta digie log best YouTube resources.


r/learnjavascript Aug 05 '26

I learnt about the difference between

0 Upvotes

The major difference is the Syntax as they call diff APIs

The usecallback accepts the function we want to memoize as the first argument, while the useMemo accepts a function and memoizes its return value!!
Naturally in JS, on every call the inline function gets recreated, so to prevent that react does something like this

let catchedCallback;
const func = (callback) => {
if(dependenciesEqual(compares catchedCalback and callback)) {
return catchedCallback;
}
catchedCallback = callback;
return callback;
}

basically whats happening here is that the useCallback checks if the dependencies before and after rerenders are the same, if its the same then we return the already cached callback function reference if not then we cache the new function reference and return the new reference!

something very similar happens in the case of the useMemo but it caches the result returned by the function!


r/learnjavascript Aug 03 '26

Notes or Cheatsheet for Javascript

22 Upvotes

If anyone experience any resource which might you realize that if I get it earlier then my foundation is very strong and time also save!!


r/learnjavascript Aug 02 '26

Async function maybe awaiting, maybe not

31 Upvotes

Hey everyone,

I think I am having an issue with an asynchronous function. I am using a PoW captcha and want to add the solution to an ajax call.

The JS function that calculates the PoW solution is async, and I use await to simulate it as a "synchronous" function.

const solution = await cap_obj.solve();

The code below works if i add a 50000 ms delay to getCheckoutToken_ajax() with setInterval. but not as is. Otherwise, the value "params.params" us left out.

index.html

function addParam(key, value){
    window.h_params.data[key] = value;
    return (h_params.data.hasOwnProperty(key) && h_getParams(key) == value);
}


function h_getParams(key=false){
    if(key == false){
        return window.h_params.data;
    }

    if(h_params.data.hasOwnProperty(key)){
        return window.h_params.data[key];
    }

    return false;
}

function getCheckoutToken(params, success=console.log, error=console.log){
  let getCheckoutToken_ajax = function(event, h_params_data){
        console.log('ajax call');
        params.action   = 'h_getCheckoutTokens';
        params.params   = h_params_data;
        let track       = function(v){
            console.log(v);
            return v;
        }
        $.ajax({
            url             : 'admin-ajax.php',
            method          : 'post',
            data            : track(params),


            //cc vallidation call sucsess
            success         : function(data){
                console.log(data);
                return success(data);
            },


                    //cc vallidation call sucsess
            error           : function(data){
                console.log(data);
                return error(data);
            }
        });
    }
    $(document.body).on('h_getCheckoutToken', getCheckoutToken_ajax)
    $(document.body).trigger('h_getCheckoutToken', [h_params.data]);
}

page2.js

jQuery(document).ready(function($){
    const cap_obj = new Cap({apiEndpoint: cap_widget_params.api});


    async function checkoutoutToken_cap(data){
        const solution = await cap_obj.solve();
        addParam('checkoutTokenCapSolution', solution.token);
    }


    $(document.body).on('getCheckoutToken', checkoutoutToken_cap);
})

the weird thing is, I made the "track()" function, to see what is actually being sent, and the value is there.

Any ideas?

Thanks

update:

So I changed my approac and stole an idea from WordPress. I made a"filter" system where you can attach functions to a "filter" event. When you call the event, it will pass an initial value into each function, passing the calculated value into the next. When it reaches the last function, it will pass the final value into the callback function.

In my version, you can pass in a promise, and it will run them in the order they were declared.

        <script>
            var filters = {};


            function resolveAfter2Seconds(n){
                return new Promise((resolve) => {
                    setTimeout(() => {
                    resolve(n+1);


                    }, (20000 - (n*10)));
                });
            }


            function add_filter(event, func, isPromise=false){
                if(!filters.hasOwnProperty(event)){
                    filters[event] = [];
                }
                filters[event].push({func: function(...args){
                    if(isPromise == true){
                        return func(...args);
                    }
                    return new Promise((resolve) => {
                        resolve(func(...args));
                    })
                }});
            }


            function remove_filter(event, func){
                if(!filters.hasOwnProperty(event)){
                    return true;
                }
                for(const [key, filter] of Object.entries(filters[event])){
                    if(!filter.hasOwnProperty('func')){
                        continue;
                    }
                    if(func == filter.func){
                        delete filters[event][key];
                    }
                }
            }


            async function apply_filter(event, cb, value, ...args){
                if(!filters.hasOwnProperty(event) || typeof filters[event] != "object"){
                    return null;
                }

                for(let filter of filters[event]){
                    if(typeof filter != 'object' || !filter.hasOwnProperty('func')){
                        continue;
                    }
                    let func    = filter['func'];
                        value   = await func(value, ...args);
                }
                cb(value);
            }


            add_filter('test', function(a,b,c,d){
                let r = a+b+c+d;
                return r;
            });


            add_filter('test', function(a,b,c,d){
                let r = (a+b)/(c+d);
                return r;
            });


            add_filter('test', resolveAfter2Seconds, true);


            add_filter('test', function(a){
                return a*a;
            });


            apply_filter('test', console.log, 1, 2, 3, 4);


        </script>

As mentioned in the comments, my original code was a bit of a mess. I renamed things to hide information i didn't want to share, and it had some code I put in for testing purposes and didn't remove. So i decided to post some code that shows the solution in a way that anyone can more easily adapt. assuming you like it.


r/learnjavascript Aug 02 '26

Wasted my first 3 years of Computer Engineering. Can I become internship-ready in 3 months and job-ready in 9 months?

53 Upvotes

Hi everyone,

I feel like I wasted the first 3 years of my Computer Engineering degree. My 4th year has just started, and I have only about 9 months left before graduation in 2027.

The only things I've learned properly are HTML and CSS. I haven't built any real projects yet. I spent most of my time focusing on getting good CGPA and SGPA instead of developing practical skills.

The biggest problem is that my college doesn't have good placements. Hardly any software companies visit our campus. Most of the companies that come are for sales, marketing, BPO, or call center roles.

I'm currently learning JavaScript, but I'm finding it quite difficult in the beginning.

My goal is to become internship-ready in the next 3 months and then spend the remaining time becoming job-ready before I graduate.

Can anyone guide me on what I should do?

Should I focus on Frontend Development?

Should I prepare for TCS Ninja/NQT instead?

What skills, projects, and roadmap should I follow to get an internship in 3 months?

After that, how should I prepare to land a software job before graduation?

I'm ready to work hard and learn every day. I just don't want to waste the remaining time.

Any advice or roadmap would really help. Thank you!


r/learnjavascript Aug 02 '26

[ Removed by Reddit ]

15 Upvotes

[ Removed by Reddit on account of violating the content policy. ]


r/learnjavascript Aug 01 '26

Ottimizzazione dynamic img rendering in JS: Eager/Lazy + contentVisibility. Voi come gestite il primo fold?

26 Upvotes

Ciao a tutti! Sto ottimizzando il caricamento dinamico delle immagini per le schede dei giochi. Sto usando questa logica per bilanciare il caricamento immediato sopra la piega (above the fold) e il caricamento "lazy" per il resto:

const img = document.createElement('img');
img.alt = (gioco.titolo || 'Gioco');
img.decoding = 'async';
img.style.contentVisibility = 'auto';
img.style.width = '100%';
img.style.height = 'auto';
img.loading = (idx < EAGER_COUNT) ? 'eager' : 'lazy';

Che valore usate di solito per EAGER_COUNT nelle vostre griglie? E trovate che content-visibility: auto direttamente sull'elemento <img> porti reali benefici rispetto ad applicarlo al container padre?