devdong

Welcome to devdong — a cozy corner where developers share stories over a cup of coffee. ☕💻

A Simple Guide to Shallow Copy vs Deep Copy in JavaScript
When developing in JavaScript, you often need to copy objects. However, simply copying with the = operator can lead to unexpected bugs—because objects are reference types. In this post, we’ll explore the differences between shallow and deep copies, when to use each, and practical implementation methods you can apply immediately.
Let’s Explore the New DOM API: setHTML
When developing for the web, you often need to insert HTML dynamically. The most common method is innerHTML, but it comes with a significant drawback—it is vulnerable to Cross-Site Scripting (XSS) attacks. To counter this, many developers have relied on external libraries like DOMPurify to safely insert HTML. Now, there's a promising new way to safely insert HTML, natively supported by web standards. This is thanks to the introduction of the new DOM API, setHTML(). In this post, we’ll dive into what setHTML() is, why it’s needed, and how to use it.
The Complete Guide to JavaScript Type Conversion
When working with JavaScript, you'll encounter situations where "5" + 1 becomes "51", while "5" - 1 becomes 4. This may be confusing at first, but it's due to JavaScript's type conversion mechanism. Type conversion refers to the process of converting one data type into another. Since JavaScript is a dynamically typed language, data types are determined and converted automatically at runtime, even without explicit type declarations by the developer. This feature can be convenient, but it can also lead to unexpected bugs. This guide covers everything you need to know about type conversion in JavaScript, from the differences between explicit and implicit conversion to object conversion and common pitfalls to avoid in real-world applications. By understanding how type conversion works, you'll be able to write safer and more predictable code.
Creating a JavaScript Calculator Without `eval()`
When writing JavaScript code, there are times when you need to execute code dynamically. In such cases, many developers often think of the eval() function. eval() provides a convenient feature that interprets a string as code and executes it. However, behind this convenience lie serious security risks and performance degradation. In this article, we’ll explore why using eval() is dangerous and take a detailed look at how to use the safer and more efficient alternative, new Function(), to execute dynamic code. Through this post, you'll gain the ability to write safer and more robust code.
Alternatives to JavaScript eval()

Alternatives to JavaScript eval()

dong5 min read
Learn why JavaScript's eval() is dangerous and how to safely replace it with new Function() using practical examples. Tips to enhance both security and performance! When working with JavaScript, you may encounter situations where you need to execute code from a string. The first thing that often comes to mind is the eval() function. However, eval() is notorious for its security vulnerabilities and performance issues. In this article, we’ll explore the dangers of eval() and how you can use the safer alternative new Function() with real-world examples.
Complete Guide to Checking Checkbox Status in JavaScript
Let’s explore how to check the status of a checkbox using JavaScript and jQuery. This includes explanations and examples of using the checked property, event listeners, prop(), and is(). User interaction is a key element in web development. Checkboxes are simple yet essential UI elements that allow users to provide consent, or choose one or multiple options. Features like “I agree to the terms and conditions” or “Auto-login” are typically implemented with checkboxes. Knowing how to check whether a checkbox is selected—or its “state”—is a must-have skill to handle user input and run corresponding logic. In this post, we’ll clearly and simply walk through multiple ways to check checkbox status using JavaScript and jQuery. By the end, you'll be able to confidently handle checkbox states in any situation.
Why You Shouldn't Use jQuery Anymore

Why You Shouldn't Use jQuery Anymore

dong4 min read
When John Resig introduced jQuery in 2006 with the motto “write less, do more,” it marked the beginning of a new era in web development. At one point, jQuery was used by 65% of the most popular websites, becoming an essential library for tasks like complex DOM manipulation, event handling, animations, and Ajax requests—all with concise code. However, as technology evolves, so does the web development environment. With the rise of modern JavaScript standards and powerful frameworks like React and Vue, jQuery's relevance has significantly declined. In this article, we’ll explore the problems jQuery once solved, and why it’s no longer the best choice for new projects.
4 Ways to Prevent Event Bubbling in jQuery
If you’ve ever clicked an element on a webpage and noticed that unintended parent element events were triggered as well, you’ve encountered a phenomenon known as event bubbling. While event bubbling can be useful when understood and used correctly, in most cases it leads to unintended behavior and makes your code harder to manage. In this post, we’ll explore what event bubbling is in jQuery and go over four effective ways to control it, complete with code examples. By the end, you'll better understand how to manage events cleanly and write more predictable and maintainable code.
The Ultimate Guide to JavaScript Prototype Chaining
From core concepts to practical application of JavaScript prototype chaining! We'll explain memory-efficient inheritance structures and the difference between prototype and proto with easy-to-understand code examples. If you're a JavaScript developer, one of the concepts you must understand is prototype chaining. This mechanism is at the core of object-oriented programming in JavaScript and can significantly improve your code's reusability and memory efficiency. Many developers, accustomed to the ES6 class syntax, sometimes overlook the importance of prototypes. However, since class syntax itself is built on top of prototypes, a solid understanding of prototype chaining will give you a deeper insight into how JavaScript works. In this article, we'll cover everything from the basic concepts of prototype chaining to its practical applications, providing content you can immediately use in your work. We'll walk through it step-by-step with code examples, so if you follow along to the end, you'll be on your way to mastering prototype chaining!
Complete Guide to JavaScript Question Mark (?) Syntax: Master These 3 Key Uses
Master the question mark (?) in JavaScript! Learn the ternary operator, optional chaining, and nullish coalescing with practical examples to write safer, cleaner code. Have you ever scratched your head while coding in JavaScript, wondering about the mysterious question mark (?) that seems to pop up everywhere? It can look like an if statement, appear in the middle of object properties, or even show up between operators. These question marks are actually incredibly useful syntax tools that make JavaScript code more concise and elegant. In real-world programming, they’re perfect for reducing repetitive code and handling exceptions efficiently. In this post, we’ll break down the three essential uses of the question mark (?) in JavaScript: the ternary operator, optional chaining, and nullish coalescing. We’ll explain why they’re important and provide clear examples so you can understand how to use them in practice. By the end, you’ll no longer fear the question mark and will know how to use it like a pro!
How to Detect Back Button Events in JavaScript
What happens when a user clicks the browser’s back button? We often think of the “back” action as simply “navigating to the previous page.” However, if we look a bit deeper, we find that this brief moment can involve a multitude of user experience issues. A draft message might disappear, a payment process could be interrupted, or even critical data might be lost. 😰 Today, let’s walk through how to detect back button events using JavaScript and improve the user experience step by step. 🚀