تمثيل المال والتواريخ والتعدادات (Enums)
في هذا الدرس 4 موضوعات
هذا الدرس مخطط له. يعرض المخطط أدناه الموضوعات التي سيغطيها، ولم يُنشر الدرس الكامل بعد.
نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.
في هذا الدرس
pick formats that never lose information.
الموضوعات المخطط لها
- Money: never
doubleorfloat(rounding errors). Use integer minor units (priceCents) or a decimal string, plus a currency code. - Dates and times: ISO 8601 with an offset or UTC, for example
2026-03-01T10:15:30Z. A time without an offset is ambiguous. - Enums: send stable uppercase strings (
"SHIPPED"), not ordinal numbers; document the allowed values. - Use the same formats in requests and responses.
- Unknown enum values from the client should give
400.
تفاصيل المخطط المبدئي
عرض عملي
{ "total": { "amount": 1999, "currency": "SAR" },
"createdAt": "2026-03-01T10:15:30Z",
"status": "SHIPPED" }اختبر فهمك
Why not 0.1 + 0.2 for money?
أظهر الإجابة
Floating point cannot represent it exactly.
التطبيق
طبّق هذا الدرس بمختبر الوحدة وتمارينها واختبارها.
تعليم الدرس كمكتمل اختياري ويمكنك التراجع عنه في أي وقت. يبقى تقدمك محفوظًا في هذا المتصفح.