Documentation
Usage
josa.pick

josa.pick

The josa.pick method selects and returns the appropriate Korean particle based on a given Korean string and particle options. This method is used within the josa (opens in a new tab) function, and the form of the particle is determined by the last character of the string.

function josa.pick(
  // The Korean string to base the particle selection on
  word: string,
  // The particle option to select
  josa:
    | '이/가'
    | '을/를'
    | '은/는'
    | '으로/로'
    | '와/과'
    | '이나/나'
    | '이에/에'
    | '이란/란'
    | '아/야'
    | '이랑/랑'
    | '이에요/예요'
    | '으로서/로서'
    | '으로써/로써'
    | '으로부터/로부터'
): string;

word: The Korean string to attach the particle to.
josa: Specifies the particle to be attached. You can choose one of the options like '이/가', '을/를', '은/는', '으로/로', '와/과', '이나/나', '이에/에', '이란/란', '아/야', '이랑/랑', '이에요/예요', '으로서/로서', '으로써/로써', '으로부터/로부터'.

Behavior

josa.pick selects the appropriate particle based on whether the last character of the given string has a final consonant and specific conditions (e.g., use of the particle '로').

It follows these rules (exceptions may apply):

  • If the last character of the string has a final consonant, typically the first particle option is used (e.g., for '이/가', '이' is used).
  • If there is no final consonant, the second particle option is used (e.g., for '이/가', '가' is used).
  • In special cases, such as when the final consonant is 'ㄹ', different rules may apply when using particles like '로'.

Examples

josa.pick('샴푸', '이/가'); // '가'
josa.pick('칫솔', '이/가'); // '이'
josa.pick('바깥', '으로/로'); // '으로'
josa.pick('내부', '으로/로'); // '로'

Demo