今日已更新 213 条资讯 | 累计 26625 条内容
关于我们

开发者

编程技术、框架工具、最佳实践

7432
篇文章

共 7432 篇 · 第 297/372 页

Dev.to

Learning about Truthy and Falsy Values in JavaScript

In JavaScript, truthy and falsy values are concepts related to boolean evaluation. Every value in JavaScript has an inherent boolean "truthiness" or "falsiness," which means they can be implicitly evaluated to true or false in boolean contexts, such as in conditional statements or logical operations. What Are Truthy Values? Truthy values are values that are evaluated to be true when used in a Boolean context. Simply put, any value that is not explicitly falsy is considered truthy. These are some truthy values Non-zero numbers: 42, -1, 3.14 Non-empty strings: "hello", "0", " " Objects and arrays: {}, [] Functions: function() {} Dates: new Date() Symbols: Symbol() BigInt values other than 0n: 10n if ( 42 ) console . log ( " This is truthy! " ); if ( " hello " ) console . log ( " Non-empty strings are truthy! " ); if ({}) console . log ( " Objects are truthy! " ); Output This is truthy ! Non - empty strings are truthy ! Objects are truthy ! What Are Falsy Values? Falsy values are values that evaluate to false when used in a Boolean. JavaScript has a fixed list of falsy values false 0 (and -0) 0n (BigInt zero) "" (empty string) null undefined NaN document.all (used for backward compatibility) if (0) console.log("This won't run because 0 is falsy."); if ("") console.log("This won't run because an empty string is falsy."); if (null) console.log("This won't run because null is falsy."); Truthy vs. Falsy Evaluation in JavaScript Whenever JavaScript evaluates an expression in a Boolean (e.g., in an if statement, a logical operator, or a loop condition), it implicitly converts the value into true or false based on whether it is truthy or falsy. With if Statement let s = " JavaScript " ; ​ if ( s ) { console . log ( " Truthy! " ); } else { console . log ( " Falsy! " ); } Output Truthy ! Logical Operators with Truthy and Falsy Logical operators like && (AND) and || (OR) work with truthy and falsy values && (AND): Returns the first falsy operand or the last operand if all are tr

Annapoorani Kadhiravan 2026-06-09 02:46 👁 8 查看原文 →
HackerNews

Show HN: HTTP/3 and raw QUIC client/server APIs for Node.js

I built this because I wanted to make outbound and accept inbound HTTP/3 and raw QUIC connections from ordinary Node.js code, without building Node from source or putting everything behind a reverse proxy. Repo: https://github.com/currentspace/http3 npm: https://www.npmjs.com/package/@currentspace/http3 It’s a native package around Rust/quiche. It supports both client and server APIs, I'm using it in a couple of projects: creating raw QUIC streams, datagrams, custom ALPN, session behavior, and H

brian_meek 2026-06-09 02:38 👁 4 查看原文 →
Dev.to

Conditional Statements in JavaScript

JAVASCRIPT CONDITIONAL STATEMENTS JavaScript conditional statements are used to make decisions in a program based on given conditions. They control the flow of execution by running different code blocks depending on whether a condition is true or false. Conditions are evaluated using comparison and logical operators. They help in building dynamic and interactive applications by responding to different inputs. Types of Conditional Statements 1. if Statement The if statement checks a condition written inside parentheses. If the condition evaluates to true, the code inside {} is executed; otherwise, it is skipped. Executes code only when a specified condition is true. Useful for making simple decisions in a program. Syntax : if ( condition ) { // code runs if condition is true } let x = 20 ; ​ if ( x % 2 === 0 ) { console . log ( " Even " ); } ​ if ( x % 2 !== 0 ) { console . log ( " Odd " ); }; Output Even 2. if-else Statement The if-else statement executes one block of code if a condition is true and another block if it is false. It ensures that exactly one of the two code blocks runs. Used when there are two possible outcomes. The else block runs when the if condition is not satisfied. let age = 25 ; ​ if ( age >= 18 ) { console . log ( " Adult " ) } else { console . log ( " Not an Adult " ) }; Output Adult 3. else if Statement The else if statement is used to test multiple conditions in sequence. It executes the first block whose condition evaluates to true. Allows checking more than two conditions. Evaluated from top to bottom until a true condition is found. const x = 0 ; ​ if ( x > 0 ) { console . log ( " Positive. " ); } else if ( x < 0 ) { console . log ( " Negative. " ); } else { console . log ( " Zero. " ); }; Output Zero . 4. Using Switch Statement (JavaScript Switch Case) The switch statement evaluates an expression and executes the matching case block based on its value. It provides a clean and readable way to handle multiple conditions for a single varia

Annapoorani Kadhiravan 2026-06-09 02:36 👁 8 查看原文 →
The Verge AI

Apple announces iPadOS 27

Today at Apple's Worldwide Developers Conference, the company announced new features coming to the iPad with iPadOS 27 including optimizations such as apps launching up to 30 percent faster by intelligently preloading needed info, and more responsive switching between multiple apps. As with the new versions of Apple's other operating systems launching this year including […]

Andrew Liszewski 2026-06-09 01:51 👁 10 查看原文 →
HackerNews

Ask HN: Why hasn't there been a real competitor to Ticketmaster yet?

It feels like every event/venue is selling tickets exclusively through Ticketmaster. Every other ticketing platform seems to only hold resale tickets in their inventory which just transfers the tickets to your Ticketmaster account when bought. With all the hate Ticketmaster has gotten and all the other ticketing platforms out there, I'm surprised Ticketmaster still has a hold of pretty much the entire market. How are they doing this? Why haven't the other platforms been able to compete?

mdni007 2026-06-09 01:28 👁 5 查看原文 →
The Verge AI

Apple announces iOS 27

Apple announced its next major iOS update, iOS 27, at WWDC 2026 on Monday. Apple is highlighting performance and design improvements, trust and safety upgrades like a Screen Time redesign, and major upgrades to Siri and Apple Intelligence. The update will be supported all the way back to the iPhone 11. A big change is […]

Jay Peters 2026-06-09 01:14 👁 8 查看原文 →