r/learnjavascript • u/Intelligent_Tree6918 • Aug 11 '26
In what cases bound method is used in production ?
Since i was repolishing my js understanding, having hard time understand bind method and it's usecases.
r/learnjavascript • u/Intelligent_Tree6918 • Aug 11 '26
Since i was repolishing my js understanding, having hard time understand bind method and it's usecases.
r/learnjavascript • u/getoutofyourhaze • Aug 10 '26
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 • u/abaezeaba • Aug 11 '26
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 • u/skamansam • Aug 10 '26
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 • u/iampankajk • Aug 08 '26
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.
this keyword. Normal vs arrow functions, and what happens when you detach a method from its object. const a = obj.getName; a()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 • u/SympathyContent9041 • Aug 08 '26
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 • u/DBGiblet • Aug 08 '26
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:
How do you usually handle carrier limitations or SMS fallback mechanisms?
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 • u/Warcraft_NK • Aug 07 '26
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 • u/Secure-Tip-2356 • Aug 07 '26
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 • u/Melbot_Studios • Aug 08 '26
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 • u/BrotherManAndrew • Aug 07 '26
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 • u/Paul_022 • Aug 06 '26
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 • u/CueMeThen • Aug 05 '26
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 • u/UnrulyRaven • Aug 04 '26
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 • u/northfieldway • Aug 04 '26
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 • u/Remote_Drawing837 • Aug 05 '26
Please bta digie log best YouTube resources.
r/learnjavascript • u/Rakeshfromsiraha • Aug 03 '26
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 • u/Ducking_eh • Aug 02 '26
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 • u/Front_End_16 • Aug 02 '26
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 • u/Imaginary_Damage_503 • Aug 02 '26
[ Removed by Reddit on account of violating the content policy. ]
r/learnjavascript • u/Maximum_Beat2034 • Aug 01 '26
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?
r/learnjavascript • u/wbport1 • Aug 01 '26
How can I run a html + js webpage on an iphone? The .html file will be on the phone.
TIA
r/learnjavascript • u/Abject_Document6006 • Jul 31 '26
Hi there !
I was just wondering as a developer how to make those famous apps animations (especially small interactions I am not meaning complexe animations) like the emoji animations on facebook when you interact with a post, the tiktok animations when you open up the app or upload a new video etc..
What kind of tools or frameworks developers may use on such level ? Do you think they use pre made animations with motion graphics softwares or they are completely coded ??
if so what are the names of those tools and frameworks needed
r/learnjavascript • u/Maximum_Beat2034 • Jul 31 '26
Nel mio motore 2D sto sistemando i componenti UI (tipo BeeButton) e mi è venuto un dubbio su come passare le coordinate al super().
Opzione A (Oggetto opzione)
```
____ super({ x, y, width, height });
```
Opzione B (Parametri singoli standard):
```
____super( x, y, width, height );
```
Voi quale preferite usare nei vostri progetti e perché? Meglio la flessibilità dell'oggetto o la pulizia dei parametri singoli?(Se usate soluzioni alternative tipo super(position, size) fatemelo sapere nei commenti!).
r/learnjavascript • u/basan4ik • Jul 31 '26
I'm reading a book called Building real-world web applications with Vue.js 3 by Joran Quinten (Packt Publishing, 2024). In the book the author builds a component to get the current position of a user by utilizing getCurrentPosition() method in Geolocation API. Here is the code snippet (full code of a component you can see on github):
const getGeolocation = async (): Promise<void> => {
await navigator?.geolocation?.getCurrentPosition(
async (position: { coords: Geolocation }) => {
coords.value = position.coords;
},
(error: { message: string }) => {
geolocationBlockedByUser.value = true;
console.error(error.message);
}
);
};
onMounted(async () => {
await getGeolocation();
});
This the excerpt of the book where he explain the code:
The getGeolocation function is being defined and, because it is dependent on user input, it is an asynchronous function by default. The promise it returns is empty because we use successCallback to update our reactive property.
I checked documentation on getCurrentPosition method and the method doesn't return promise, it just uses callbacks. So, is it valid to use async/awaits here? The code from the snippet doesn't work btw)
UPD: 1) The problem was that my mac was blocking geolocation. I tested it from mobile phone's browser and it works. 2) Actually, both versions work: with and without async/awaits. But as u/senocular wrote async/awaits are not necessary here. Kudos to everyone for your help:)