r/JavaScriptTips • u/xplodivity • Jun 20 '23
r/JavaScriptTips • u/France_linux_css • Jun 16 '23
Unocss reggex rules // could you help me with the reggex ?
r/JavaScriptTips • u/eyuelberga • Jun 12 '23
3 Ways To Implement Infinite Scroll
r/JavaScriptTips • u/Zafar_Kamal • Jun 12 '23
Advanced Vanilla JavaScript Tip: Functional Programming with Higher-Order Functions
self.welovecodesr/JavaScriptTips • u/xplodivity • May 11 '23
JavaScript Promises vs Async Await vs Callback Hell (Explained in 5 minutes)
r/JavaScriptTips • u/derjanni • May 11 '23
Frontend JavaScript Secrets: What Books Won’t Teach You
r/JavaScriptTips • u/DevYour_World • May 04 '23
Tips for starting a project with three.js, A-Frame, and WebXR
Three.js, A-Frame, and WebXR are powerful technologies that can be used to create immersive 3D experiences on the web. However, starting a project with these technologies can be overwhelming, especially if you're new to 3D development. In this debate, we'll discuss tips and best practices for starting a project with three.js, A-Frame, and WebXR.
r/JavaScriptTips • u/soshace_devs • Apr 03 '23
Exploring Modern JavaScript: A Comprehensive Guide to ES6 and Beyond
r/JavaScriptTips • u/Wolverine_6011 • Mar 19 '23
Learn Javascript online javascript-Roadmap for beginners.
JavaScript quickly became popular because it allowed web developers to add interactivity and dynamic content to their web pages, which was previously not possible with static HTML. It was standardized as ECMAScript in 1997, and subsequent versions of JavaScript have been based on this standard.
https://www.guerillateck.com/2023/03/learn-javascript-online-javascript.html
r/JavaScriptTips • u/[deleted] • Feb 14 '23
Check falsy value in an array in JavaScript #shorts #javascript
r/JavaScriptTips • u/david_bragg • Dec 23 '22
What made you start programming?
Curious to know what made you guys start learning to code.
I'll start first. I wanted to make my own game
r/JavaScriptTips • u/irisbstehn • Dec 14 '22
Great overview of the best GitHub JavaScript resources
Do you know any others that might help for starters or intermediate JS programmers?
https://medium.com/@Iris-bs/do-you-know-those-awesome-github-resources-for-javascript-4dc2b0046ffa
r/JavaScriptTips • u/dasher_nick • Dec 06 '22
Building Your First Isomorphic Javascript Library
Writing code in Next.js (or SSR) and need it to run on both the server and client? I recently started working in isomorphic javascript, and it was way more challenging than I originally realized to do it well.
While at DoorDash, I have spent my time focused on building and maintaining two isomorphic javascript libraries: one for analytics, and another for experimentation (e.g. feature flagging, a/b testing). There were times during the process where I began to wonder if the challenges outweighed the benefits. I wrote a blog post here to reflect on the different types of challenges I faced, using a super simple example library to illustrate the points. I hope this guide is helpful to anyone either considering to build an isomorphic javascript, and let me know your thoughts!
r/JavaScriptTips • u/No-Upstairs-2813 • Dec 03 '22
JavaScript Callback Functions
Despite not knowing what the callback function is, chances are that you already use it without even realizing it. Methods like .map(), .filter(), and .reduce() all make use of callback functions.
Although callbacks can be confusing, you still need to learn them thoroughly as they form a critical concept in JavaScript. You can’t get very far without knowing callbacks.
Check out this post to learn what callbacks are, why they’re important, and how to use them.
r/JavaScriptTips • u/saymynamelol • Nov 14 '22
eventlistener is not returning anything i'm really confused
Ok so in my function 'updateCartFromArray()' I managed to add an specific ID to each span that has the class 'removeFromBasket'.

The only problem is that, somehow i cant manage to add an eventlistener to each span. For some reasong when i click it it simply return nothing.
I just need to return the id of each span that has "removeFromBasket" class when i click it. But now it is simply returning NOTHING
Can you guys please help me? I dont want the solution i just want to understand what i'm doing wrong.
JS:
const data = [
{
id: 1,
img: "./img/jaqueta.svg",
nameItem: "Lightweight Jacket",
description:
"Adicione um pouco de energia ao seu guarda-roupa de inverno com esta jaqueta vibrante...",
value: 100,
addCart: "Adicionar ao carrinho",
tag: ["Camisetas"],
},
{
id: 2,
img: "./img/gorro.svg",
nameItem: "Black Hat",
description:
"O gorro Next.js chegou! Esta beldade bordada tem um ajuste confortável que garante que...",
value: 100,
addCart: "Adicionar ao carrinho",
tag: ["Acessórios"],
},
{
id: 3,
img: "./img/mascara.svg",
nameItem: "Mask",
description:
"Esta máscara facial durável é feita de duas camadas de tecido tratado e possui presilhas...",
value: 40,
addCart: "Adicionar ao carrinho",
tag: ["Acessórios"],
},
{
id: 4,
img: "./img/camiseta_preta.svg",
nameItem: "T-Shirt",
description:
"Esta t-shirt é imprescindível no seu guarda-roupa, combinando o caimento intemporal de...",
value: 100,
addCart: "Adicionar ao carrinho",
tag: ["Camisetas"],
},
{
id: 5,
img: "./img/camiseta_branca.svg",
nameItem: "Short-Sleeve T-Shirt",
description:
"Agora você encontrou a camiseta básica do seu guarda-roupa. É feito de um mais grosso...",
value: 100,
addCart: "Adicionar ao carrinho",
tag: ["Camisetas"],
},
{
id: 6,
img: "./img/moletom.svg",
nameItem: "Champion Packable Jacket",
description:
"Proteja-se dos elementos com esta jaqueta embalável Champion. Esta jaqueta de poliést...",
value: 100,
addCart: "Adicionar ao carrinho",
tag: ["Camisetas"],
},
];
let itensInTheList = []
for (i = 0; i < data.length; i++) {
div = document.createElement('div')
div.className = "itenBox"
div.id = data[i].id
img = document.createElement('img')
img.src = data[i].img
textDiv = document.createElement('div')
textDiv.className = "textElement"
p = document.createElement('p')
p.id = "type"
p.innerHTML = data[i].tag[0]
nameSpan = document.createElement('span')
nameSpan.id = "name"
nameSpan.innerHTML = data[i].nameItem
descriptionSpan = document.createElement('span')
descriptionSpan.id = "description"
descriptionSpan.innerHTML = data[i].description
priceSpan = document.createElement('span')
priceSpan.id = "price"
priceSpan.innerHTML = data[i].value
basketSpan = document.createElement('span')
basketSpan.className = "addToBasket"
basketSpan.id = i
basketSpan.innerHTML = "Adicionar ao carrinho"
basketSpan.addEventListener('click', addItemToArray)
textDiv.appendChild(p)
textDiv.appendChild(nameSpan)
textDiv.appendChild(descriptionSpan)
textDiv.appendChild(priceSpan)
textDiv.appendChild(basketSpan)
//console.log(textDiv)
div.appendChild(img)
div.appendChild(textDiv)
placeItens = document.querySelector('.itens')
placeItens.appendChild(div)
}
function addItemToArray(event) {
divElement = document.createElement('div')
divElement.className = "itemInTheBasket"
divImage = document.createElement('div')
img = document.createElement('img')
img.src = data[event.target.id].img
img.height = 90
divDescription = document.createElement('div')
divDescription.className = "someDescription"
spanName = document.createElement('span')
spanName.id = "name"
spanName.innerHTML = data[event.target.id].nameItem
spanPrice = document.createElement('span')
spanPrice.id = "price"
spanPrice.innerHTML = data[event.target.id].value
spanRemove = document.createElement('span')
spanRemove.className = "removeFromBasket"
spanRemove.innerHTML = "Remover do carrinho"
divDescription.appendChild(spanName)
divDescription.appendChild(spanPrice)
divDescription.appendChild(spanRemove)
divImage.appendChild(img)
divElement.appendChild(divImage)
divElement.appendChild(divDescription)
itensInTheList.push(divElement)
updateCartFromArray()
}
function updateCartFromArray(){
emptyCart = document.querySelector('.boughtFullList')
for (j = 0; j < itensInTheList.length; j++) {
emptyCart.appendChild(itensInTheList[j])
removeButtonPosition = itensInTheList[j].querySelector('.removeFromBasket')
removeButtonPosition.id = j
removeButtonPosition.addEventListener('click', console.log('ok'))
}
}HTML:
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cool Clothes</title>
<link rel="stylesheet" href="./css/style.css">
<script src="./js/index.js" defer></script>
<link rel="icon" href="https://static.thenounproject.com/png/1445763-200.png">
</head>
<body>
<header>
<h1>Cool Clothes</h1>
<ul>
<li>Todos</li>
<li>Acessórios</li>
<li>Calçados</li>
<li>Camisetas</li>
</ul>
</header>
<main>
<div class="container">
<div class="itens">
</div>
<div class="shoppingList">
<div class="searchInput">
<input type="text" placeholder="Digite aqui sua pesquisa">
<button class="searchButton">Pesquisar</button>
</div>
<div class="headerShoppingCart">Carrinho de compras</div>
<!--
<div class="boughtEmptyItensList">
<span><strong>Carrinho vazio</strong></span><span>Adicione Itens</span>
</div>
-->
<div class="boughtFullList">
<!--<div class="itemInTheBasket">
<div><img src="./img/camiseta_branca.svg" height="85px" alt=""></div>
<div class="someDescription">
<span id="name">ok1</span>
<span id="price">ok2</span>
<span id="removeFromBasket">ok3</span>
</div>
</div>
-->
</div>
<div class="amountAndPrices">
<div class="amount"><span>Quantidade</span><span>90</span></div>
<div class="amount"><span>Preço</span><span>90</span></div>
</div>
</div>
</div>
</main>
</body>
</html>r/JavaScriptTips • u/geshan • Oct 28 '22
How to create a React search bar a step-by-step guide
r/JavaScriptTips • u/xplodivity • Oct 13 '22
async and defer made easy | JavaScript Performance
Async and Defer are two important concepts in JavaScript as it provides information about the fastest way to load JavaScript. Understanding async ,defer and how they are different from normal script tags is also asked during interviews. This 6 minute video explains everything you need to know about async, defer, why or when to use them and their differences.
Link: https://www.youtube.com/watch?v=RaPMjzYFF9Y
r/JavaScriptTips • u/blazitysoftware • Sep 05 '22
OPTIMIZING images for the web - what you really must know in 2022
r/JavaScriptTips • u/MLG-newbslayer • Aug 10 '22
Is there a way to output a return string onto a webpage without using an alert()?
Basically title. I'm trying to make a Rock, Paper, Scissors game for The Odin Project, and this is one thing I'm just stuck on.
r/JavaScriptTips • u/geshan • Aug 05 '22