Seif Eddine Slimen Seif Eddine Slimen - 1 year ago 35
Javascript Question

need explanation of this javascript function

**Hello, can anyone explain to me this code i don't understand some of it


what the "!n" after the return means?
what these two functions does exactly?**


The first part basically means "if a is not a string, return a, otherwise replace all \ with \\.

The second part is about the same, but with % and %25.

!n.isString appears to be "not n.isString" or "is not a string". To understand this better you can think of it as this: !(n.isString), where n is the Object/Class that implements a isString method.

The a ? b : c operator is called a ternary operator and is basically the same as

if (a) {
    return b
} else {
    return c