r/JavaScriptTips • u/France_linux_css • Jun 08 '22
r/JavaScriptTips • u/xplodivity • Jun 07 '22
Customisable Toast Notification using JavaScript
I built a highly customisable toast notification using vanilla JavaScript that allows user to control the position, type (success or error), message content, and duration of display of the toast notification. I learnt a lot of important JavaScript concepts while building this project, and I highly recommend you to try it out as well. Here's a video explanation of building the project from scratch
Link: https://www.youtube.com/watch?v=jJCUnPd1ymk
r/JavaScriptTips • u/Varun_123 • Jun 04 '22
Generating new HTML elements on the page after taking an input
I am trying to build something where after a button press, I want to load a new HTML element (input type). As of now, I am using the DOM model, but is there any way where I can pre-write the HTML code beforehand and only make it visible after I press the button?
r/JavaScriptTips • u/Icy_Pressure_9690 • Jun 02 '22
Problem with understanding checkerboard code
Hi, I am working on an exercise in a textbook and I am struggling to understand how the code works, the code produces a 8X8 checkerboard of alternating spaces and hashtags based on whether two loops starting at 0 and incremented by 1 per cycle is odd or even.
x++ and y ++ mean to increase variable by 1 but use the original value so;
-1st Loop will be (x + y) = 0 + 0
-2nd Loop will be 1 + 1 3rd will be 2 + 2 etc - thus accounting for all even numbers and so printing " "
within the board = ""
But how is the code testing for odd numbers when they increment and are added together in such a way to only produce even numbers? How is the else activated?
If the code produces horizontal lines of alternating spaces and hashtags until it reaches up to 8 (board += "\n"), what part of the code is telling it to stop at 8 lines vertically?
` let size = 8;
let board = "";
for (let y = 0; y < size; y++) {
for (let x = 0; x < size; x++) {
if ((x + y) % 2 == 0) {
board += " ";
} else {
board += "#";
}
}
board += "\n";
}r/JavaScriptTips • u/psycho_buddha • May 31 '22
Best way to transform object in JS
Hello all,
I have an object that needs to be transformed and I am not really sure how to approach it. The end result should also be an object with some difference:
- ConnString should be splitted into ConnString_Server which will have value tcp:myserver--- ConnString_InitialCatalog which will have value CRMTests, etc.
- All the nested values should be flattened, so I will need to have NeoLicense_Owner, NeoLicense_Key, SSO_Audience, etc
At the moment I am trying to loop through the object and do stuff based on the object keys.
What would you suggest as a best practice in this case? Is it better to handle everything in one function or it's better to try to handle in several smaller ones? I think I can find the solution that will work, so I don't want a finished solution, I would just like to get an advice on what's the best practice in this situation.
Thanks in advance!
const data = {
"AlertName": "test reporting",
"AlertEmail": "[email protected]",
"AllowedHosts": "*",
"Label": "Companies",
"ConnString": "Server=tcp:myserver.database.windows.net,1433;Inital Catalog=CRMTest;Persist Security Info=False;User ID=testuser;Password=testuser@zz;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;",
"DataEncryption": {
"IV": "kdsdtyv8x/A?D(G+",
"Key": "v9y/B?t7w!z%C&F)J",
},
"AdminDashboard": false,
"Hangfire": {
"WorkerCount": 10
},
"HangfireRedisPrefix": "test-prod",
"NeoLicense": {
"Owner": "Test Developer License",
"Key": "C8QXP4LWRPG3QUI9PPY4T8A582SDRUEXPCFRGMA",
"EditorOwner": "test - 1 WebApp LLC - Unlimited WebServer Lic",
"EditorKey": "55756A2756949TRE593265EF1EF",
"JSPMOwner": "test-OEM Developer License",
},
"OctToken": "95308651-0fd2-4baa-ace3-1ffa98a3dcc7",
"RedisConnect": "northdev.redis.cache.windows.net:6381,password=okcz6oLA3piAzCaEuflYu,ssl=True,abortConnect=False",
"SSO": {
"Audience": "all",
"BaseURL": "https://login-test.com",
"ClientId": "test.com",
"ClientSecret": "7a227fr-8f75-77-af70-th788",
}
}r/JavaScriptTips • u/imyousuf18 • May 31 '22
Which JS framework is in demand and It will also be in the near future? Any Suggestions?
r/JavaScriptTips • u/Substantial_Date_375 • May 19 '22
Help me with JavaScript Please 😣🤟🏼
r/JavaScriptTips • u/SjoerdvanBommel • May 11 '22
Learn everything about textures in three.js and react three fiber in this YouTube tutorial
r/JavaScriptTips • u/xplodivity • Apr 16 '22
Tic tac toe made easy | Vanilla JavaScript
I came up with an easy implementation of tic tac toe using pure vanilla javascript. I was told that in some frontend interviews, people were asked to implement tic tac toe within an hour and by using minimal css. I think this solution mentioned in the link below should be pretty easy to understand and implement.
Link: https://www.youtube.com/watch?v=O0tfoMN9Rjo

r/JavaScriptTips • u/dordchn • Mar 14 '22
A cool vscode plugin that provides you with code snippets on demand!
r/JavaScriptTips • u/jbean92 • Mar 09 '22
Front End Engineer - Interview Help
I made it to the final round of interviews and I'm really excited about this opportunity. I've been a developer for 4+ years and feel confident with my HTML, CSS & JS skills. However, I always get nervous when it comes to interviews. Over the past few days, I've built a few small React projects, watched multiple mock interviews on YouTube, and brushed up on my vanilla JS skills. I'm definitely ready to move on from my current position, so I want to do everything I can to prepare. If anyone has any additional advice, I'd really appreciate it! Thank you!
r/JavaScriptTips • u/[deleted] • Feb 20 '22
Learning Javascript, trying to understand camelCase. Why does capitalization matter in the left side of the equation, but not in the right? Example included.
Learning Javascript, trying to understand camelCase. Why does capitalization matter in the left side of the equation, but not in the right? Example included.
Trying to learn Javascript and using FreeCodeCamp's example. Having a difficult time learning how capitalization is applied and why it matter in some instances, but not others.
See example problem below!
// Setup
const lastName = "Lovelace";
// Only change code below this line
const secondToLastLetterOfLastName = lastName[lastName.length - 3]; // Change this line
If the const is defining Lovelace as forever and it will never change, doesn't that mean I have to write lastName as intended too, with the lower level "L"?
Why is in the second const, I have to capitalize the L in Last? That would make it not constant or const, no?
Unless the rules don't apply, and it's camelCase only to the right side of equation? but in the left, it has to follow camelCase? Or does camelCase always apply everywhere?
We are defining lastName as a const, so shouldn't it also be lastName and NOT LastName?
r/JavaScriptTips • u/farhan_tanvir_bd • Feb 09 '22
Auto Resizable SelectBox
Hello everyone.
I have recently faced a problem with resizing the SelectBox (Though it is a basic issue). I have solved the issue and written an article about that. Please check the link below.
I think there is more way to solve this issue. I would be grateful if anyone shares any other way to solve this issue.
Thanks.
https://farhan-tanvir.medium.com/auto-resizable-selectbox-react-typescript-no-jquery-7b01c5a6343a
r/JavaScriptTips • u/kage_heroin • Jan 14 '22
Need Recommendations for working with DOM and JS
Hi, I come from desktop c/cpp development background and I'm aiming to be a decent full-stack web developer.
I've already acquired several decent books that for example cover ASP.NET and Angular etc.
But here's the thing: before learning these frameworks, I'd rather learn pure JS development first. attaching it to HTML and especially working with DOM not starting with frameworks first.
do you have recommendations/opinions on this matter? maybe a good book?
r/JavaScriptTips • u/Thembani297 • Dec 14 '21
i'm using node + puppeteer so when scraping , have you encountered an issued whereby , some of your data , doesnt always go to corresponding columns in excel, lets say if an element doesnt exist, how do i solve this
r/JavaScriptTips • u/deepak_vi • Nov 24 '21
Weird Parts of JavaScript: Working with Date
In this article, I will explain how you can create a simple utility library for all your needs by using plain JavaScript.
//date.js
exports.formatDuration = (ms) => {
ms = Math.abs(ms);
const time = {
day: Math.floor(ms / 86400000),
hour: Math.floor(ms / 3600000) % 24,
minute: Math.floor(ms / 60000) % 60,
second: Math.floor(ms / 1000) % 60,
millisecond: Math.floor(ms) % 1000,
};
return Object.entries(time)
.filter((val) => val[1] !== 0)
.map(([key, val]) => `${val} ${key}${val !== 1 ? "s" : ""}`)
.join(", ");
};
// main.js
console.log(formatDuration(34325055574));
// 397 days, 6 hours, 44 minutes, 15 seconds, 574 millisecondshttps://javascript.plainenglish.io/weird-parts-of-javascript-working-with-date-c002f98be30c
r/JavaScriptTips • u/TheWebUiGuy • Nov 17 '21
Interesting ways to manage users in React
r/JavaScriptTips • u/OmegaNutella • Oct 01 '21
How To Create An Instant Javascript Game | Introduction
r/JavaScriptTips • u/JerLam2762 • Oct 01 '21
Javascript SDK - AI engines aggregator
Hi r/javascript, my teamates and I are working on Eden AI Javascript SDK!
Eden AI provides one API connected to the best AI engines (AWS, Azure, GCP, but also smaller providers) offering different AI services (computer vision, machine translation, speech-to-text, etc.). As a developer, you can easily switch between different providers (Amazon, Google, Microsoft, etc.) and also combine AI engines. You can also monitor the use of this AI services on one easy to use platform.
Here's some ready-to-use examples on our GitHub. Don't hesitate to tell us what do you think about it ([email protected]) and if you would use it. We really need some feedbacks. It would also help us if you put a star! :)
r/JavaScriptTips • u/KrunalLathiya • Sep 20 '21
