While RunWithElevatedPrivileges is applicable in Server side code how a CSOM or JSOM code gets permission to do Add/Edit/Update operation on list?
JSOM code runs under the permissions of the current user. So, its access level is similar to the access level of the current user. You can't elevate permissions here since it would be a huge security issue.
As for CSOM code (C#), you can impersonate credentials by using
context.Credentials or by creating an app which uses app only permissions. App only permissions lets you run the app using the so called "elevated privileges."