वार्षिक सालाना भुगतान करें और हर सशुल्क प्लान पर 2 महीने मुफ़्त पाएं। प्लान देखें
साइन इन करें मुफ़्त शुरू करें

कोड अनुवादक

इनपुट
कोड
function add(a, b) { return a + b; }
नमूना आउटपुट 27 अक्तूबर 2026 को बनाया गया

export function add(a: number, b: number): number { return a + b; }

Notes:

  • The TypeScript version explicitly accepts and returns number.
  • Unlike the JavaScript original, calls with strings or other non-number values are rejected at compile time.
  • TypeScript types are erased at runtime, so JavaScript callers can still pass incompatible values unless runtime validation is added.
  • number includes floating-point values, NaN, and Infinity.
  • JavaScript’s usual numeric behavior still applies, including floating-point precision issues and coercion at runtime.
इसे इस्तेमाल करें कोड अनुवादक फ़ॉर्म इस नमूने के इनपुट से भरा खुलता है; जो चाहें बदलें।