Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Javascript数字格式化 千K万W

ASecurity

封装一个JavaScript函数,用于将数字格式化为带单位的字符串(千用k,万用w)。该函数必须支持通过参数控制小数位数,既可以指定固定小数位,也可以保留原始数字的小数位数。

2 stars
0 votes
0 copies
0 views
Added 9/27/2026
developmentjavascriptjava

Security Analysis

A100/100

Scanned 9/27/2026

$npx -y skills add David-Li0406/meta-skill-evloving --skill 'javascript数字格式化-千k万w' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Javascript数字格式化 千K万W?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Javascript数字格式化 千K万W
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/david-li0406-javascript-k-w-meta-skill-evloving/badge)](https://www.skillsdirectory.com/skills/david-li0406-javascript-k-w-meta-skill-evloving)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
id: "ef7e6f68-95a5-45f5-b60d-473d8c423a6d"
name: "JavaScript数字格式化(千k万w)"
description: "封装一个JavaScript函数,用于将数字格式化为带单位的字符串(千用k,万用w)。该函数必须支持通过参数控制小数位数,既可以指定固定小数位,也可以保留原始数字的小数位数。"
version: "0.1.0"
tags:
  - "javascript"
  - "数字格式化"
  - "工具函数"
  - "前端"
triggers:
  - "js 数字格式化 千k 万w"
  - "formatNumberWithUnits"
  - "数字转k w单位"
  - "保留小数位格式化数字"
---

# JavaScript数字格式化(千k万w)

封装一个JavaScript函数,用于将数字格式化为带单位的字符串(千用k,万用w)。该函数必须支持通过参数控制小数位数,既可以指定固定小数位,也可以保留原始数字的小数位数。

## Prompt

# Role & Objective
You are a JavaScript utility developer. Write a function `formatNumberWithUnits` that formats numbers into strings with 'k' (thousands) or 'w' (ten-thousands) units based on specific user requirements.

# Operational Rules & Constraints
1. **Unit Conversion Logic**:
   - If the number is less than 1000, return the number as a string without a unit.
   - If the number is greater than or equal to 1000 but less than 10000, divide the number by 1000 and append the unit 'k'.
   - If the number is greater than or equal to 10000, divide the number by 10000 and append the unit 'w'.

2. **Decimal Place Control**:
   - The function signature must be `formatNumberWithUnits(number, fixedDecimalPlace)`.
   - The second parameter `fixedDecimalPlace` controls the decimal precision.
   - If `fixedDecimalPlace` is provided as a number, the result must be formatted to exactly that many decimal places (e.g., using `toFixed`).
   - If `fixedDecimalPlace` is `null` or not provided, the function must preserve the original decimal places of the input number as much as possible.

# Anti-Patterns
- Do not use `Intl.NumberFormat` for this specific 'k'/'w' logic unless explicitly asked, as the user requested custom unit handling.
- Do not hardcode specific test values (like 123456) into the function logic.

# Examples
- `formatNumberWithUnits(123456)` should output '12.3456w' (preserving original decimals).
- `formatNumberWithUnits(123456, 2)` should output '12.35w' (fixed to 2 decimals).

## Triggers

- js 数字格式化 千k 万w
- formatNumberWithUnits
- 数字转k w单位
- 保留小数位格式化数字

Attribution

David-Li0406David-Li0406
View sourceSee grades on GitHubMore from David-Li0406 →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Clean Code

Pragmatic coding standards - concise, direct, no over-engineering, no unnecessary comments

304955 votes

Browser Extension Developer

Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.

286712 votes

Seo Optimizer

SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.

2222 votes

Google Official Seo Guide

Official Google SEO guide covering search optimization, best practices, Search Console, crawling, indexing, and improving website search visibility based on official Google documentation

1862 votes

Writing Plans

Use when you have a spec or requirements for a multi-step task, before touching code

2927051 votes
View all in development →