r/JavaScriptTips • • Jun 20 '23

Authentication vs Authorization Explained for NOOBS!!

Thumbnail
youtube.com
3 Upvotes

r/JavaScriptTips • • Jun 16 '23

Unocss reggex rules // could you help me with the reggex ?

Post image
3 Upvotes

r/JavaScriptTips • • Jun 12 '23

3 Ways To Implement Infinite Scroll

Thumbnail
medium.com
3 Upvotes

r/JavaScriptTips • • Jun 12 '23

Advanced Vanilla JavaScript Tip: Functional Programming with Higher-Order Functions

Thumbnail self.welovecodes
3 Upvotes

r/JavaScriptTips • • May 11 '23

JavaScript Promises vs Async Await vs Callback Hell (Explained in 5 minutes)

Thumbnail
youtube.com
3 Upvotes

r/JavaScriptTips • • May 11 '23

Frontend JavaScript Secrets: What Books Won’t Teach You

Thumbnail
medium.com
3 Upvotes

r/JavaScriptTips • • May 04 '23

Tips for starting a project with three.js, A-Frame, and WebXR

3 Upvotes

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 • • Apr 03 '23

Exploring Modern JavaScript: A Comprehensive Guide to ES6 and Beyond

Thumbnail
soshace.com
3 Upvotes

r/JavaScriptTips • • Mar 19 '23

Learn Javascript online javascript-Roadmap for beginners.

3 Upvotes

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 • • Feb 14 '23

Check falsy value in an array in JavaScript #shorts #javascript

Thumbnail
youtube.com
3 Upvotes

r/JavaScriptTips • • Feb 14 '23

Interesting

Post image
3 Upvotes

r/JavaScriptTips • • Dec 23 '22

What made you start programming?

3 Upvotes

Curious to know what made you guys start learning to code.
I'll start first. I wanted to make my own game


r/JavaScriptTips • • Dec 14 '22

Great overview of the best GitHub JavaScript resources

3 Upvotes

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 • • Dec 06 '22

Building Your First Isomorphic Javascript Library

3 Upvotes

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!

https://doordash.engineering/2022/12/06/five-challenges-to-building-an-isomorphic-javascript-library/


r/JavaScriptTips • • Dec 03 '22

JavaScript Callback Functions

3 Upvotes

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 • • Nov 14 '22

eventlistener is not returning anything i'm really confused

3 Upvotes

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 • • Oct 28 '22

How to create a React search bar a step-by-step guide

Thumbnail
geshan.com.np
3 Upvotes

r/JavaScriptTips • • Oct 13 '22

async and defer made easy | JavaScript Performance

3 Upvotes

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 • • Sep 17 '22

Buffers and streams in Node.js

Thumbnail
medium.com
3 Upvotes

r/JavaScriptTips • • Sep 07 '22

Javascript and the event loop

Thumbnail
medium.com
3 Upvotes

r/JavaScriptTips • • Sep 05 '22

OPTIMIZING images for the web - what you really must know in 2022

Thumbnail
youtube.com
3 Upvotes

r/JavaScriptTips • • Aug 10 '22

Is there a way to output a return string onto a webpage without using an alert()?

3 Upvotes

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 • • Aug 05 '22

How to wait 1 second in JavaScript (using setTimeout, Promise, and Delay)

Thumbnail
geshan.com.np
3 Upvotes

r/JavaScriptTips • • Jul 31 '22

Text Animation Using CSS Only |

Thumbnail
youtu.be
3 Upvotes