Think the `+` sign is only for adding numbers? Adorable. It's also a lightning-fast type cast. `const pages = +"50";` turns a string into a number. But feed it `"50 pages"` and it silently returns `NaN`, poisoning every calculation that follows. Is this a brilliant, high-performance tool, or a cryptic bug-factory that `parseInt()` was designed to prevent? #GaboTips #JavaScript
GABRIEL CLEMENTE 👨🏼💻🟨’s Post
More Relevant Posts
-
𝐈 𝐛𝐞𝐭 𝐲𝐨𝐮 𝐝𝐢𝐝𝐧’𝐭 𝐤𝐧𝐨𝐰 𝐭𝐡𝐢𝐬… . . . There’s a 30-𝐲𝐞𝐚𝐫-𝐨𝐥𝐝 𝐛𝐮𝐠 in JavaScript — and it’ll never be fixed. 𝐭𝐲𝐩𝐞𝐨𝐟 𝐧𝐮𝐥𝐥 === "𝐨𝐛𝐣𝐞𝐜𝐭"; // 𝐭𝐫𝐮𝐞 🤯 This is not a quirk — it’s a mistake. When JS was created in 1995, 𝐧𝐮𝐥𝐥 was stored as all 0’s in memory. Objects also used 0 as a type tag. So JS confused them. Now fixing it would break the web. 💀 #JavaScript #ProgrammingHistory #WebDev #JavaScript #WebDevelopment #ProgrammingHistory
To view or add a comment, sign in
-
Think you can start a new line after `return`? Cute. JavaScript's "helpful" semicolon insertion will stab you in the back. `return\n{ user: 'Gabo' }` becomes `return;`. Your function now silently returns `undefined`. The object vanishes. Is this a clever rule for cleaner code, or a silent logic-killer that semicolons exist to prevent? #GaboTips #JavaScript
To view or add a comment, sign in
-
The “Result Pattern” is a great way to improve not only the code flow, but also the developer experience for those who’ll work with your code down the line. No need to try/catch random errors and guess error codes, everything is typed and you know exactly what you want/need to handle. #javascript #typescript #developerexperience #designpatterns #softwaredevelopment
To view or add a comment, sign in
-
-
In the upcoming Webiny v6, we’re rewriting a lot of internals, and the public API for extensions will be completey new. As we’re rewriting things, we’re taking the opportunity to improve the code base and DX for external teams but also for ourselves. This is just one example: the “Result Pattern”. Widely used in C#, proved to be a great pattern for managing and documenting a variety of potential errors that can be returned as a result of an operation. And not a single try/catch is necessary!! 🥳 #designpatterns #developerexperience #softwaredevelopment
The “Result Pattern” is a great way to improve not only the code flow, but also the developer experience for those who’ll work with your code down the line. No need to try/catch random errors and guess error codes, everything is typed and you know exactly what you want/need to handle. #javascript #typescript #developerexperience #designpatterns #softwaredevelopment
To view or add a comment, sign in
-
-
Converting input type number by using parseInt or Number() function or using a plus operator for instance const num = +value. We can instead use the valueAsNumber property which gives the value as number type simple 🪄 Picture Credit: Steve Sewell 🙌 . . #javascript #javascriptTips
To view or add a comment, sign in
-
-
The JavaScript filter() method is a powerful way to create a new array containing only the elements that meet a certain condition. It goes through each item in the array and returns the ones that pass the test you provide. For example, to get all even numbers from an array: javascript const numbers = [1, 2, 3, 4, 5]; const evens = numbers.filter(num => num % 2 === 0); console.log(evens); // Output: [2, 4] Use filter() whenever you need to sift through data and extract only what’s relevant, making your code more declarative and concise! #JavaScript #WebDevelopment #CodingTips #ArrayMethods
To view or add a comment, sign in
-
⚡ Developer Shortcut You’ll Actually Use 👇 Want to test an API quickly without building a full front-end? Open your browser console and run this 👇 fetch('https://lnkd.in/d6EMttce') .then(res => res.json()) .then(console.log) ✅ Works like a mini Postman — straight from your browser. ✅ Great for checking responses instantly. Sometimes the simplest tricks save the most time. 😎 #WebDevelopment #JavaScript #DeveloperTips #CodingShortcuts #FullStackDeveloper #DeveloperVinod
To view or add a comment, sign in
-
-
Going back to basics 🌱 What does "typeof null" returns ?? Surprisingly, it returns "object" Yes it has been a "bug" in Javascript since the very beginning as i have read. When Javascript was first designed, values were stored in a way that caused "null" to be mistakenly tagged as an "object". And even after years, it remains that way for backward compatibility. So, "typeof null" is "object" but null is not an "object". #Javascript #Frontend
To view or add a comment, sign in
-
-
#JavaScript Ever needed to parse URL query parameters without messy string splitting? 🙂 const urlParams = new URLSearchParams(window.location.search); const userId = urlParams.get('user'); const category = urlParams.get('category'); • No more manual string parsing • Built-in browser support 🌐 • Clean and readable code • Handles encoding automatically #WebDevelopment #Frontend #CodingTips #BrowserAPIs Created with postcreate.me ✨
To view or add a comment, sign in
-
-
🚀 𝗨𝗻𝗱𝗲𝗿𝘀𝘁𝗮𝗻𝗱𝗶𝗻𝗴 𝗣𝗿𝗼𝘅𝘆 𝗶𝗻 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 ⤵️ Recently, I was studying about Proxy in JavaScript and here’s what I’ve learned 👇 ⇾ What is 𝗽𝗿𝗼𝘅𝘆? A Proxy lets you wrap an object and control what happens when someone reads, writes, or modifies its properties. Proxy objects are commonly used to log property accesses, validate, format, or sanitize inputs, and so on. You can create a Proxy with two parameters: • 𝙩𝙖𝙧𝙜𝙚𝙩: the original object which you want to proxy. • 𝙝𝙖𝙣𝙙𝙡𝙚𝙧: an object that defines which operations will be intercepted and how to redefine intercepted operations. ⇾ 𝙜𝙚𝙩 - when a property is read Controls what happens when someone tries to access a property. ⇾ 𝙨𝙚𝙩 - when a property is modified Controls what happens when someone tries to assign a property. #JavaScript #WebDevelopment #FrontendDevelopment #CodingJourney #LearnInPublic
To view or add a comment, sign in
-
More from this author
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development