Vuosittain Maksa vuosittain ja saat 2 kuukautta ilmaiseksi jokaiseen maksulliseen tilaukseen. Katso tilaukset
Kirjaudu sisään Aloita ilmaiseksi

Koodikatselmointi

Syöte
Koodi
function add(a, b) { return a + b; }
Esimerkkitulos Tehty 27 lokakuuta 2026

Bugs

  • Line 1: Parameters a and b have implicit any types when noImplicitAny is enabled.
  • Line 1: The return type is unspecified. Because + behaves differently for numbers and strings, the function’s intended behavior is ambiguous.

Security

  • No direct security vulnerabilities are present.
  • Explicit numeric types prevent unintended string concatenation or coercion when this function is used with loosely typed input.

Performance

  • The implementation is already optimal for numeric addition.
  • No additional allocations or unnecessary operations are performed.

Style

  • Add parameter and return type annotations for clarity and type safety.
  • Expand the one-line function to improve readability and maintainability.
function add(a: number, b: number): number {
  return a + b;
}
Käytä tätä Koodikatselmointi Lomake avautuu tämän esimerkin syötteillä täytettynä; muuta mitä haluat.