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

标签:#JavaScript

找到 660 篇相关文章

AI 资讯

JavaScript Data Types Explained: Primitive vs Non-Primitive Data Types

JavaScript Data Types: Primitive and Non-Primitive Data Types Data types are an important concept in JavaScript because they define the kind of value a variable can store. Understanding data types helps developers write reliable and efficient code. What is a Data Type? A data type defines what kind of value a variable can hold. Example let name = " John " ; // String let age = 25 ; // Number let isActive = true ; // Boolean In the above example, each variable stores a different type of value. Types of Data Types in JavaScript JavaScript data types are broadly classified into two categories: Primitive Data Types Non-Primitive Data Types Primitive Data Types Primitive data types store a single and simple value. Characteristics Store a single value. Immutable (cannot be changed directly). Compared by value. Stored directly in memory. Types of Primitive Data Types 1. String Used to store textual data. let name = " John " ; 2. Number Used to store numeric values. let age = 25 ; let price = 99.99 ; 3. Boolean Represents either true or false . let isLoggedIn = true ; 4. Undefined A variable that has been declared but not assigned a value. let city ; console . log ( city ); // undefined 5. Null Represents the intentional absence of a value. let user = null ; 6. Symbol Used to create unique identifiers. let id = Symbol ( " id " ); 7. BigInt Used to store very large integers beyond the safe Number limit. let largeNumber = 123456789012345678901234567890 n ; Non-Primitive Data Types Non-primitive data types store multiple values or complex data structures. Characteristics Can store collections of data. Mutable (their contents can be modified). Compared by reference. Stored as references in memory. Types of Non-Primitive Data Types 1. Array Used to store multiple values in a single variable. let colors = [ " red " , " green " , " blue " ]; 2. Object Used to store data as key-value pairs. let person = { name : " John " , age : 25 }; 3. Function Functions are reusable blocks of co

2026-06-06 原文 →
AI 资讯

Cypress Testing: Complete Beginner's Guide

Section 1: Getting Started with Cypress 1. Installing and Setting Up Cypress Prerequisites Before installing Cypress, ensure you have Node.js installed on your machine. Cypress requires Node.js 18.x or 20.x and above. You should also have an existing React project or create a new one. Check your Node.js version by running this command in your terminal: node --version # Should output v18.x.x or higher Creating a React Project (Optional) If you don't have an existing React project, create one using Vite which is the recommended approach for new React projects: npm create vite@latest my-react-app -- --template react cd my-react-app npm install Installing Cypress Navigate to your React project directory and install Cypress as a development dependency. Cypress is a fairly large package, so the installation might take a minute or two: npm install cypress --save-dev # Or using yarn yarn add cypress --dev Opening Cypress for the First Time After installation, open Cypress for the first time. This will create the initial folder structure and configuration files: npx cypress open When Cypress opens for the first time, you'll see a welcome screen where you can choose between E2E Testing and Component Testing. Select E2E Testing to get started with end-to-end tests. Cypress will then prompt you to choose a browser. You can select Chrome, Firefox, Edge, or Electron. Choose your preferred browser and click Start E2E Testing in [Browser] . Adding NPM Scripts Add convenient scripts to your package.json for running Cypress tests: { "scripts" : { "dev" : "vite" , "build" : "vite build" , "cy:open" : "cypress open" , "cy:run" : "cypress run" , "test:e2e" : "start-server-and-test dev http://localhost:5173 cy:run" } } Tip: Use npm run cy:open for interactive development with the Cypress Test Runner. Use npm run cy:run for headless execution in CI/CD pipelines. 2. Understanding Cypress Project Structure Project Directory Overview After initializing Cypress, you'll notice several new fold

2026-06-06 原文 →
AI 资讯

I Built a Free Open-Source EU AI Act / NIST AI RMF / ISO 42001 Crosswalk Tool - Here Is What I Found

Every week I see the same question in AI governance communities: "We already have NIST AI RMF implemented. Does that cover our EU AI Act obligations?" The honest answer is: sometimes yes, sometimes partially, and sometimes not at all. The problem is that nobody had built a clean, free, interactive tool that showed exactly which controls map to which, how strong those mappings actually are, and where the genuine gaps are. So I built one. Live tool: suhanasayyad.github.io GitHub: SuhanaSayyad / eu-ai-act-crosswalk-tool Interactive crosswalk mapping EU AI Act obligations to NIST AI RMF and ISO 42001 controls, with mapping strength indicators, gap analysis, and source links. 30 controls mapped. Free and open source. EU AI Act × NIST AI RMF × ISO 42001 - Interactive Compliance Crosswalk Tool An open-source tool that maps EU AI Act obligations to their equivalents in NIST AI RMF and ISO 42001, with mapping strength indicators, gap analysis, and source document links. Built for compliance teams, AI governance practitioners, and anyone trying to understand how these three frameworks relate to each other. Live demo: https://suhanasayyad.github.io/eu-ai-act-crosswalk-tool Built by: Suhana Sayyad | MSc Cybersecurity, TUS Athlone Why I built this Every organisation dealing with the EU AI Act is being asked the same questions: "We already have NIST AI RMF controls in place. Does that cover our EU AI Act obligations?" "We're pursuing ISO 42001 certification. Does that satisfy the regulation?" The honest answer is: sometimes yes, sometimes partially, and sometimes not at all. The problem is that nobody had built a clean, free, interactive tool that showed exactly which… View on GitHub What the tool does The EU AI Act / NIST AI RMF / ISO 42001 Interactive Crosswalk Tool maps 30 EU AI Act obligations to their nearest equivalents in NIST AI RMF and ISO 42001. For each mapping it shows a strength rating - Strong, Partial, Indirect, or No Equivalent - so compliance teams know which map

2026-06-06 原文 →
AI 资讯

From an Abandoned To-Do App to a Smart Productivity Engine: Upgrading Taskr into Solomon's Taskr

What I Built : ( https://github.com/Sai-Emani25/Solomon-s-Taskr ) I transformed my initial, bare-bones task management application, Taskr, into Solomon's Taskr—a significantly smarter, more robust productivity platform. The original project started as a standard way to log to-dos, but it lacked the intelligence to actually help manage time or prioritize effectively. With Solomon's Taskr, I wanted to build a system that doesn't just store data, but actively assists the user. Building this project means a lot to me because it represents a leap from writing basic applications to architecting intelligent, dynamic systems that solve real-world workflow bottlenecks. Demo Link to Final Repository: https://github.com/Sai-Emani25/Solomon-s-Taskr Link to Original Repository: https://github.com/Sai-Emani25/Taskr (Here is a quick walkthrough of Solomon's Taskr in action!) The Comeback Story The original Taskr project had been sitting in my repositories, unfinished and gathering dust. It was a classic case of starting a project with good intentions but abandoning it once the basic structure was complete. It could create, read, update, and delete tasks, but that was it. For the Finish-Up-A-Thon, I decided to completely resurrect and overhaul it. Here are the key changes and implementations that turned it into Solomon's Taskr: Complete Codebase Refactoring: I stripped down the old, inefficient logic and rebuilt the architecture to be highly scalable and maintainable. Intelligent Prioritization ("The Solomon Touch"): I integrated smart features to help organize and prioritize tasks rather than just listing them chronologically. (Note: If you integrated Gemini API or LLMs here for smart tagging, explicitly mention it!) Enhanced UI/UX: I moved away from the clunky, basic interface of the original Taskr and implemented a clean, responsive dashboard that provides a real-time overview of pending and completed tasks. Optimized Data Handling: I refined how the application processes and st

2026-06-06 原文 →
AI 资讯

Why I stopped reading "Old vs New" posts

Why I stopped reading "❌ Old vs ✅ New" posts I used to scroll past them. Then I started ignoring them. Now? I don't read them at all. Not because they're "wrong". But because they're incomplete . The problem with "❌ Old vs ✅ New" These posts make everything look easy: One error One fix One clean "New Way" Three bullet points Save the post Done. Right? No. What these posts don't show you 🔹 The 200 failed deployments before that one working fix 🔹 The 300+ errors you solve along the way — not just one 🔹 The Vercel pipelines that break for no documented reason 🔹 The "New Way" that also fails in production 🔹 The gap between documentation and reality What happens in production That clean "New Way" code snippet? It might work on your local machine. But in production, with real traffic, real data, real edge cases? It can fail. Hard. And no three-line post prepares you for that. Why I stopped reading Because these posts teach me solutions to problems I don't have yet . But they don't teach me how to think when nothing works. They don't teach me: How to read error logs properly How to trace a pipeline failure across services How to stay consistent after multiple failed deploys How to know when the "New Way" is actually worse What actually helped me Not templates. Not shortcuts. Real experience: 200+ failed deployments 300+ errors solved (one by one) Broken pipelines fixed by understanding, not copy-paste Production live — not a "demo" or a "tutorial" This is not a "❌ vs ✅" post I'm not giving you a "Here's the fix". Because the real fix isn't three lines of code. It's patience. It's persistence. It's failing and getting back up. And no post can save that to your bookmarks. 👇 Have you ever followed a "New Way" post and had it fail in production?

2026-06-06 原文 →
AI 资讯

Why DaloyJS Is the Best Backend (or BFF) for Your Electron App

If you've ever built an Electron app that needs a backend, you know the problem. You want something lightweight, something that runs on Node, something where you don't spend three hours configuring Swagger, and something that doesn't make you feel like you're setting up a microservices architecture just to expose two endpoints to your own desktop UI. I've shipped Electron apps with Express. I've tried Fastify. Both work, but they leave you doing a lot of plumbing yourself. Then I found DaloyJS , and honestly, it clicked. The Electron Backend Problem Here's the thing about Electron: your renderer process is basically a browser, and your main process is a Node.js server. When you need data from external APIs, or you need a clean layer between your UI and your business logic, you want a BFF, a Backend for Frontend. A thin server that composes upstream calls, holds the session, and returns exactly the shape your UI needs. DaloyJS was built for this role. The docs even say so plainly: typed upstream client, fetchGuard for safe egress, session handling, and edge runtime support. That combination is exactly the BFF toolkit. Contract-First Means Less Glue The killer feature for desktop apps is contract-first routing. You define a route once, and DaloyJS gives you validation, OpenAPI 3.1 docs, and a typed in-process client all from the same source. No stale spec files. No writing types by hand. Here's what a basic Electron BFF route looks like: import { z } from " zod " ; import { App , requestId , secureHeaders , rateLimit } from " @daloyjs/core " ; import { serve } from " @daloyjs/core/node " ; const app = new App ({ bodyLimitBytes : 1 << 20 , requestTimeoutMs : 5 _000 , docs : true , // auto-mounts /docs and /openapi.json }); app . use ( requestId ()); app . use ( secureHeaders ()); app . use ( rateLimit ({ windowMs : 60 _000 , max : 120 })); app . route ({ method : " GET " , path : " /settings/:userId " , operationId : " getUserSettings " , request : { params : z . objec

2026-06-05 原文 →
AI 资讯

waitForResponse() timing: the one-line fix with a non-obvious mental model

The test hung for 30 seconds. The response had already fired. One moved line fixed it. The test hung for 30 seconds, then timed out. The browser had received the response. The page had loaded. The data was there. The test was still waiting. The wizard I was writing a helper to walk through a 4-step booking wizard. After clicking "Next" on step 1, the page does a full navigation — window.location.href to step 2. Step 2 immediately loads doctor data from the API. The helper looked like this: await Promise . all ([ page . waitForURL ( /step=2/ ), step1Next . click ()]); await page . waitForResponse ( r => r . url (). includes ( ' /doctors ' )); Standard pattern: wait for navigation, then wait for the data request. Timeout. Every time. What I checked first The URL pattern. Maybe /doctors wasn't matching. Opened the network tab. The request was there: GET /api/v1/doctors , 200, 47ms. Correct URL, correct response. The page looked fine. The data was rendered. The test said it was waiting for a response that had already happened. Added waitForLoadState . Still hung. Added an explicit waitForSelector for an element that was clearly on the page. That passed. Then waitForResponse hung again. The response existed. The test couldn't see it. What was actually happening page.waitForResponse() is not a query. It doesn't look at what happened. It registers a listener — from that exact moment forward — and waits for the next matching response. The sequence in my code: Promise.all resolves when the URL changes to step=2 By the time the URL changed, step 2 had already loaded Step 2 had already sent and received /api/v1/doctors Then waitForResponse registered its listener Now it's waiting for the next /doctors response Which never comes Playwright doesn't buffer missed events. If the response fired before the listener was registered — it's gone. The fix await Promise . all ([ page . waitForURL ( /step=2/ ), page . waitForResponse ( r => r . url (). includes ( ' /doctors ' )), step1Next

2026-06-05 原文 →
AI 资讯

Full-stack RBAC with NestJS Clean Architecture + Next.js FSD

Built a full-stack RBAC admin starter: NestJS (Clean Architecture) + Next.js 16 (FSD). JWT refresh, permission-gated UI, sheet-based CRUD. MIT. Looking for feedback. ⚡ Next.js 16 Admin Dashboard Template Architecture: Strictly adheres to Feature-Sliced Design (FSD) to prevent codebase rot in large applications. Key Features: Full-scale Role-Based Access Control (RBAC) UI, URL-driven advanced tables (TanStack Table v8), global caching (TanStack Query v5), and dynamic sheet-based UX configurations using shadcn/ui and Tailwind v4. Quality Assurance: Pre-configured with Playwright for End-to-End (E2E) testing and automated GitHub Actions CI. 🛡️ NestJS Clean Architecture REST API Architecture: Implements strict layered Clean Architecture (Presentation ➔ Application ➔ Domain 🡨 Infrastructure) ensuring zero database/framework lock-in. Key Features: Advanced authentication via JWT refresh rotation, stateful RBAC with high-performance Redis permissions caching, and enterprise-grade security structures. Quality Assurance: Achieves ~98% test coverage across domain and application layers using Jest.

2026-06-05 原文 →
AI 资讯

TypeORM Reaches 1.0 After Nearly a Decade, Signalling Renewed Maintenance

TypeORM 1.0 is the first major release of the open-source TypeScript and JavaScript ORM since its inception in 2016. This version modernizes platform requirements, removes deprecated APIs, and introduces numerous bug fixes and new features. TypeORM now supports ECMAScript 2023, dropping older Node.js versions and dependencies while enhancing security and migration processes. By Daniel Curtis

2026-06-05 原文 →
AI 资讯

Web Security: OWASP Top 10 and How to Fix Them (2026)

Web Security: OWASP Top 10 and How to Fix Them (2026) Security isn't a feature you add later — it's built into every layer. Here's how the top 10 vulnerabilities work and how to prevent them. #1 Broken Access Control // ❌ Vulnerable: User can access anyone's data app . get ( ' /api/users/:id ' , ( req , res ) => { const user = await db . users . findById ( req . params . id ); res . json ( user ); // No check if requester owns this data! }); // ✅ Secure: Always verify ownership app . get ( ' /api/users/:id ' , async ( req , res ) => { // Check: Is the logged-in user requesting their OWN data? if ( req . params . id !== req . user . id && req . user . role !== ' admin ' ) { return res . status ( 403 ). json ({ error : ' Access denied ' }); } const user = await db . users . findById ( req . params . id ); res . json ( user ); }); // ✅ Better: Use middleware for all protected routes const requireOwnership = ( resourceType ) => async ( req , res , next ) => { const resource = await db [ resourceType ]. findById ( req . params . id ); if ( ! resource ) return res . status ( 404 ). json ({ error : ' Not found ' }); if ( resource . userId !== req . user . id && req . user . role !== ' admin ' ) { return res . status ( 403 ). json ({ error : ' Access denied ' }); } req . resource = resource ; // Attach for route handler next (); }; app . get ( ' /api/posts/:id ' , auth , requireOwnership ( ' posts ' ), ( req , res ) => { res . json ( req . resource ); }); #2 Cryptographic Failures // ❌ Storing passwords in plain text or weak hashing const password = " password123 " ; db . users . insert ({ email , password }); // NEVER DO THIS! // ✅ Proper password hashing with bcrypt const bcrypt = require ( ' bcrypt ' ); const SALT_ROUNDS = 12 ; // Higher = slower = more secure (12 is good balance) async function hashPassword ( password ) { return bcrypt . hash ( password , SALT_ROUNDS ); } async function comparePassword ( password , hash ) { return bcrypt . compare ( password , hash ); /

2026-06-05 原文 →
AI 资讯

Web Security Basics: Every Developer Must Know (2026)

Web Security: OWASP Top 10 and How to Fix Them (2026) Security isn't a feature you add later — it's built into every layer. Here's how the top 10 vulnerabilities work and how to prevent them. #1 Broken Access Control // ❌ Vulnerable: User can access anyone's data app . get ( ' /api/users/:id ' , ( req , res ) => { const user = await db . users . findById ( req . params . id ); res . json ( user ); // No check if requester owns this data! }); // ✅ Secure: Always verify ownership app . get ( ' /api/users/:id ' , async ( req , res ) => { // Check: Is the logged-in user requesting their OWN data? if ( req . params . id !== req . user . id && req . user . role !== ' admin ' ) { return res . status ( 403 ). json ({ error : ' Access denied ' }); } const user = await db . users . findById ( req . params . id ); res . json ( user ); }); // ✅ Better: Use middleware for all protected routes const requireOwnership = ( resourceType ) => async ( req , res , next ) => { const resource = await db [ resourceType ]. findById ( req . params . id ); if ( ! resource ) return res . status ( 404 ). json ({ error : ' Not found ' }); if ( resource . userId !== req . user . id && req . user . role !== ' admin ' ) { return res . status ( 403 ). json ({ error : ' Access denied ' }); } req . resource = resource ; // Attach for route handler next (); }; app . get ( ' /api/posts/:id ' , auth , requireOwnership ( ' posts ' ), ( req , res ) => { res . json ( req . resource ); }); #2 Cryptographic Failures // ❌ Storing passwords in plain text or weak hashing const password = " password123 " ; db . users . insert ({ email , password }); // NEVER DO THIS! // ✅ Proper password hashing with bcrypt const bcrypt = require ( ' bcrypt ' ); const SALT_ROUNDS = 12 ; // Higher = slower = more secure (12 is good balance) async function hashPassword ( password ) { return bcrypt . hash ( password , SALT_ROUNDS ); } async function comparePassword ( password , hash ) { return bcrypt . compare ( password , hash ); /

2026-06-05 原文 →
AI 资讯

Rust Ownership System Explained for JavaScript Developers

Rust Ownership System Explained for JavaScript Developers Quick context (why you're writing this) I was trying to rewrite a small utility I’d written in JavaScript—a function that takes a string, splits it into words, and returns the longest one. In JS it’s trivial: you pass the string around, mutate arrays, and nothing blows up. When I attempted the same thing in Rust, the compiler kept yelling at me about “use of moved value” and “cannot borrow as mutable because it is also borrowed as immutable”. I spent a good chunk of an afternoon staring at those errors, thinking I’d missed some syntax detail, only to realize the real issue was a completely different way of thinking about data. If you’ve ever felt that Rust’s compiler is being overly pedantic, you’re not alone—but once you grasp what it’s protecting you from, the frustration turns into appreciation. The Insight Rust doesn’t treat variables like JavaScript’s loosely‑typed references. Instead, it enforces ownership at compile time. Three ideas tend to surprise developers coming from a garbage‑collected world: Move semantics – assigning a value to another variable moves it; the original is no longer usable unless you explicitly clone it. Borrowing rules – you can have either many immutable references or exactly one mutable reference to a piece of data, but never both at the same time. Lifetimes – the compiler tracks how long references are valid, preventing dangling pointers without a garbage collector. The first two are the ones that trip people up most often, and they directly address the class of bugs JavaScript developers know all too well: accidental shared‑state mutations and use‑after‑free‑like mistakes (though in JS they show up as weird undefined values rather than crashes). Let’s look at each with a concrete example, show the common mistake, and then see how to do it right. How (with code) Move semantics – the “you can’t use it after you give it away” surprise fn main () { let greeting = String :: from

2026-06-05 原文 →