Saturday, August 29, 2026 · #3
Explain the code
Read the snippet and explain what it does in plain words. The judge scores your explanation. You get 3 tries per day.
typescriptvuejs/core
export const toDisplayString = (val: unknown): string => {
return isString(val)
? val
: val == null
? ''
: isArray(val) ||
(isObject(val) &&
(val.toString === objectToString || !isFunction(val.toString)))
? isRef(val)
? toDisplayString(val.value)
: JSON.stringify(val, replacer, 2)
: String(val)
}