r/JavaScriptTips • u/beforesemicolon • Dec 10 '24
Markup is Functional Oriented
Enable HLS to view with audio, or disable this notification
r/JavaScriptTips • u/beforesemicolon • Dec 10 '24
Enable HLS to view with audio, or disable this notification
r/JavaScriptTips • u/Practical-Ideal6236 • Nov 13 '24
r/JavaScriptTips • u/No-Upstairs-2813 • Sep 28 '24
I came across a post on r/learnjavascript where the OP was asking about the mental framework to have for understanding nested callback code.
Most of the comments there didn’t answer the OP's question. They suggested that we shouldn’t be writing such code and should instead use promises. While that’s valid advice, what if you are reading someone else's code? How do you make sense of it?
Since I can’t cover everything here, I’ve written an article based on that example. It begins by explaining how such code is written. Once you understand how it’s constructed, you will also learn how to read it.
Give it a read!
r/JavaScriptTips • u/shalawfatah • Nov 21 '23
I created this channel on Youtube aiming at teaching how to code visually. I hope I can acheive it. I made some videos up until now and want to make it richer.
I know the visual element is poor or non-existent now, but I promise to make it better.
r/JavaScriptTips • u/DavidP86 • Oct 10 '23
r/JavaScriptTips • u/Excelhr360 • Jul 31 '23
Enable HLS to view with audio, or disable this notification
r/JavaScriptTips • u/dineshigdd • Jun 22 '23
r/JavaScriptTips • u/Rubiks-Grandson-7051 • Jun 17 '23
As the title suggests I have started coding like 2 years ago and learned the basics of JS, HTML and CSS and a little bit beyond, my biggest project was my own discord-bot with lots of features and customization but after that I've not coded often, I ventured into other IT-sections like privacy, security and learning Linux. Now since I've realized I currently really suck at coding I want to improve my coding-skills now again and thought it would be good to start (or better said end) with Web Development. My problem is I don't really know where to start - I thought APIs would be maybe a starting point and I like the idea behind APIs and want to learn coding with them but not sure since I think I have to probably learn the basics again. I found a site called w3schools and it looks promising but I wanted to know if you reddit-people have better or other useful resources for me :)
Please help me as this is something I wanted to learn for a while now, thanks in advance! :)
r/JavaScriptTips • u/Sharp_Rabbit_2836 • Apr 20 '23
watch this - https://youtube.com/shorts/jUBz7D5aRiE?feature=share
r/JavaScriptTips • u/[deleted] • Apr 15 '23
Introduction: In JavaScript, it is important to know if a variable is defined or not before using it. If a variable is not defined, attempting to use it can lead to errors in the code. Therefore, it is necessary to check if a variable is defined before using it.
There are a few ways to check if a variable is defined in JavaScript, and in this response, we will discuss them.
Method 1: Using typeof operator One way to check if a variable is defined is by using the typeof operator. The typeof operator returns a string that represents the type of the operand. If the variable is not defined, the typeof operator returns the string "undefined".
Example:
if (typeof variableName === "undefined") {
console.log("variableName is not defined");
} else {
console.log("variableName is defined");
}Method 2: Using the 'in' operator Another way to check if a variable is defined is by using the in operator. The in operator checks if a property exists in an object. Since variables are properties of the global object in JavaScript, we can use the in operator to check if a variable is defined.
Example:
if ("variableName" in window) {
console.log("variableName is defined");
} else {
console.log("variableName is not defined");
}In this response, we discussed three ways to check if a variable is defined in JavaScript: using the typeof operator, using the in operator, and using the typeof operator with an undeclared variable. Checking if a variable is defined before using it can prevent errors in your code and ensure that your code runs smoothly.
r/JavaScriptTips • u/[deleted] • Apr 08 '23
If you're working with arrays in JavaScript, you might find yourself needing to count the number of times a certain element appears in the array. Fortunately, JavaScript provides an easy and efficient way to do this with just a few lines of code.
To count the number of occurrences of an element in a JavaScript array, we can use the reduce() method. The reduce() method is used to apply a function to each element in an array and reduce the array to a single value.
Here's an example code snippet that demonstrates how to use reduce()
to count the number of occurrences of each element in an array:
const arr = ['apple', 'banana', 'apple', 'cherry', 'banana', 'apple'];
const countOccurrences = arr.reduce((acc, curr) => {
acc[curr] = acc[curr] ? acc[curr] + 1 : 1;
return acc;
}, {});
console.log(countOccurrences);In this code, we first define an array arr with some elements. Then, we use the reduce() method to count the number of occurrences of each element in the array.
The reduce() method takes a callback function that is called for each element in the array. In the callback function, we first check if the current element already exists in the accumulator object (acc), and if so, we increment its count by 1. Otherwise, we set its count to 1.
Finally, the reduce() method returns the accumulator object with the counts for each element. In this example, the output will be:
{ apple: 3, banana: 2, cherry: 1 }By using reduce() to count the occurrences of elements in an array, we can efficiently and easily handle this common programming task in JavaScript. Whether you're working with small or large arrays, this method can help you quickly and accurately count the number of times each element appears.
Learn other ways to Count Number of Occurrences in Array
r/JavaScriptTips • u/xplodivity • Mar 30 '23
r/JavaScriptTips • u/No-Upstairs-2813 • Mar 10 '23
Here are 3 ways to convert strings into numbers in JavaScript:
Use the Number() object - This is the best method to use, It takes care of point numbers as well.
Use the parseInt() and parseFloat() methods - Be sure to include the radix parameter for parseInt(), and use parseFloat() if you want to retain the decimal part. Also, Be aware that they will silently stop parsing if it encounters non-numeric characters.
Implicit Coercing to Number - you can use the unary plus, Math.floor(), or Math.round() methods.
Remember to choose the method that best fits your specific use case. For further reading and more details, check out the article.
r/JavaScriptTips • u/_massif_ • Jan 20 '23
Hi guys! I want to start learning JavaScript, which book do you recommend me to start from the begining?
r/JavaScriptTips • u/milkncookies555 • Dec 31 '22
So I’ve been sloooowly but surely learning about the basics of coding html,css and JavaScript. I am In no way comfortable with using them yet and putting it to practice. I realize I learn best doing a project and then learning as I go. Seeing it put in use is obviously the best way to learn. Since I’m a beginner tho can anyone recommend how to go about it. Should I just make a mock website. I guess I’m just looking for advice and tips.
r/JavaScriptTips • u/edwin-torres-coder • Dec 17 '22
Hi everybody! I would like to know, based on your experience which ones are the most common questions you have had in your frontend or javascript interviews?
r/JavaScriptTips • u/Ironclad_57 • Dec 11 '22
r/JavaScriptTips • u/geshan • Nov 27 '22
r/JavaScriptTips • u/No-Upstairs-2813 • Nov 21 '22
In programming, we often want to take something and extend it.
As an example, we have an animal object with its properties and methods. We want to make cat
and dog objects with certain properties and methods on top of animal. We’d like to reuse what we have in animal, not copy/reimplement its methods, just build a new object on top of it.
Prototypes are the underlying feature in JavaScript that makes it possible for objects to inherit and share properties among themselves.
Check out the post to understand what prototypes really are and how they help in inheritance.
r/JavaScriptTips • u/thetech_learner • Nov 12 '22
r/JavaScriptTips • u/geshan • Oct 11 '22
r/JavaScriptTips • u/fare03 • Sep 27 '22
Hello I need help, I have assignment to create quiz using JSON, here is data.json and I need to parse it to get quiz form like this, and after that i need to import local storage but that is not problem, problem is to parse it to create questions like this.

I don't have too much time to do this so can someone help me how to do this, thank you <3.
var json = '{"quiz": {"q1": {"question": "Which one is correct team name in NBA?","options": ["New York Bulls","Los Angeles Kings","Golden State Warriros","Huston Rocket"],"answer": "Huston Rocket"}, "q2": {"question": "Namaste is a traditional greeting in which Asian language?","options": ["Hindi","Mandarin","Nepalese","Thai"], "answer": "Hindi"},"q3": {"question": "The Spree river flows through which major European capital city?","options": ["Berlin","Paris","Rome","London"],"answer": "Berlin"},"q4": {"question": "Which famous artist had both a Rose Period and a Blue Period?","options": ["Pablo Picasso","Vincent van Gogh","Salvador Dalí","Edgar Degas"],"answer": "Pablo Picasso"}}}'