/r/javascript

Photograph via //r/javascript

Chat about javascript and javascript related projects. Yes, typescript counts. Please keep self promotion to a minimum/reasonable level.

All about the JavaScript programming language.

Subreddit Guidelines


Specifications:


Resources:


Related Subreddits:

r/LearnJavascript

r/node

r/typescript

r/reactjs

r/webdev

r/WebdevTutorials

r/frontend

r/webgl

r/threejs

r/jquery

r/remotejs

r/forhire


/r/javascript

2,399,224 Subscribers

1

Showoff Saturday (January 18, 2025)

Did you find or create something cool this week in javascript?

Show us here!

0 Comments
2025/01/18
08:00 UTC

1

[AskJS] Help How do I make an event happen again

So I just started learning Js and after a few courses I tried to make a To do list. I made that when you dont type any task but click submit, the message appeares that says that you need to input a text and it works. Also added so it dissapperes after 2 seconds. But the problem is that after it dissappeares when i click the button, the text doesn't show up. Pls help. This is the code

const zadatak=document.querySelector('#unos')
const dugme=document.querySelector('#dugme')
const todo=document.querySelector('.todo')
const lista=document.querySelector('#lista')
const msg=document.querySelector('.msg')

dugme.addEventListener('click',ispisi)

function ispisi(e){
    e.preventDefault()
    
    if(zadatak.value==='')
    {
        msg.innerHTML='Unesite obavezu'
        msg.classList.add('error')
        setTimeout(()=>msg.remove(),2000)
    }
    else
    {
        console.log(zadatak.value)
    }
       
}


6 Comments
2025/01/17
22:12 UTC

0

[AskJS] structuredClone

The function structuredClone is not useful to clone instances of programmer's defined classes (not standard objects) because it doesn't clone methods (functions). Why it is so?

6 Comments
2025/01/17
19:51 UTC

1

WTF Wednesday (January 15, 2025)

Post a link to a GitHub repo or another code chunk that you would like to have reviewed, and brace yourself for the comments!

Whether you're a junior wanting your code sharpened or a senior interested in giving some feedback and have some time to spare to review someone's code, here's where it's happening.

Named after this comic

1 Comment
2025/01/15
08:00 UTC

0

[AskJS] Detection of null pointer, my experience with chatGPT

So recently I came across a problem, reviewing of JS code using an automated process.

I used ChatGPT API to detect places where a null pointer issue might be possible and unhandled in the code (like accessing innerHTML of an element using querySelector), It is great at detection. With my small data set it can detect issues with 90% accuracy, but it also throws false positive (flagging places where null checks are already handled).

With the two prompt approach, i.e passing the errors from the first prompt and ask the second prompt to find the false positive cases. The accuracy doesn't have any significant change.

Made me wonder is there any way to detect these runtime issues in JS, especially if it is handled. I tried multiple dynamic analysis tools like jalanga, JScent.

6 Comments
2025/01/14
19:57 UTC

Back To Top