/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.
Specifications:
Resources:
Related Subreddits:
/r/javascript
Did you find or create something cool this week in javascript?
Show us here!
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)
}
}
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?
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.
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.