let errors = ['auth/claims-too-large	The claims payload provided to setCustomUserClaims() exceeds the maximum allowed size of 1000 bytes.','auth/email-already-exists	The provided email is already in use by an existing user. Each user must have a unique email.','auth/id-token-expired	The provided Firebase ID token is expired.','auth/id-token-revoked	The Firebase ID token has been revoked.','auth/insufficient-permission	The credential used to initialize the Admin SDK has insufficient permission to access the requested ','authentication resource. Refer to Set up a Firebase project for documentation on how to generate a credential with appropriate permissions and use it to ','authenticate the Admin SDKs.','auth/internal-error	The ','authentication server encountered an unexpected error while trying to process the request. The error message should contain the response from the ','authentication server containing additional information. If the error persists, please report the problem to our Bug Report support channel.','auth/invalid-argument	An invalid argument was provided to an ','authentication method. The error message should contain additional information.','auth/invalid-claims	The custom claim attributes provided to setCustomUserClaims() are invalid.','auth/invalid-continue-uri	The continue URL must be a valid URL string.','auth/invalid-creation-time	The creation time must be a valid UTC date string.','auth/invalid-credential	The credential used to ','authenticate the Admin SDKs cannot be used to perform the desired action. Certain ','authentication methods such as createCustomToken() and verifyIdToken() require the SDK to be initialized with a certificate credential as opposed to a refresh token or Application Default credential. See Initialize the SDK for documentation on how to ','authenticate the Admin SDKs with a certificate credential.','auth/invalid-disabled-field	The provided value for the disabled user property is invalid. It must be a boolean.','auth/invalid-display-name	The provided value for the displayName user property is invalid. It must be a non-empty string.','auth/invalid-dynamic-link-domain	The provided dynamic link domain is not configured or ','authorized for the current project.','auth/invalid-email	The provided value for the email user property is invalid. It must be a string email address.','auth/invalid-email-verified	The provided value for the emailVerified user property is invalid. It must be a boolean.','auth/invalid-hash-algorithm	The hash algorithm must match one of the strings in the list of supported algorithms.','auth/invalid-hash-block-size	The hash block size must be a valid number.','auth/invalid-hash-derived-key-length	The hash derived key length must be a valid number.','auth/invalid-hash-key	The hash key must a valid byte buffer.','auth/invalid-hash-memory-cost	The hash memory cost must be a valid number.','auth/invalid-hash-parallelization	The hash parallelization must be a valid number.','auth/invalid-hash-rounds	The hash rounds must be a valid number.','auth/invalid-hash-salt-separator	The hashing algorithm salt separator field must be a valid byte buffer.','auth/invalid-id-token	The provided ID token is not a valid Firebase ID token.','auth/invalid-last-sign-in-time	The last sign-in time must be a valid UTC date string.','auth/invalid-page-token	The provided next page token in listUsers() is invalid. It must be a valid non-empty string.','auth/invalid-password	The provided value for the password user property is invalid. It must be a string with at least six characters.','auth/invalid-password-hash	The password hash must be a valid byte buffer.','auth/invalid-password-salt	The password salt must be a valid byte buffer','auth/invalid-phone-number	The provided value for the phoneNumber is invalid. It must be a non-empty E.164 standard compliant identifier string.','auth/invalid-photo-url	The provided value for the photoURL user property is invalid. It must be a string URL.','auth/invalid-provider-data	The providerData must be a valid array of UserInfo objects.','auth/invalid-provider-id	The providerId must be a valid supported provider identifier string.','auth/invalid-o','auth-responsetype	Only exactly one O','auth responseType should be set to true.','auth/invalid-session-cookie-duration	The session cookie duration must be a valid number in milliseconds between 5 minutes and 2 weeks.','auth/invalid-uid	The provided uid must be a non-empty string with at most 128 characters.','auth/invalid-user-import	The user record to import is invalid.','auth/maximum-user-count-exceeded	The maximum allowed number of users to import has been exceeded.','auth/missing-android-pkg-name	An Android Package Name must be provided if the Android App is required to be installed.','auth/missing-continue-uri	A valid continue URL must be provided in the request.','auth/missing-hash-algorithm	Importing users with password hashes requires that the hashing algorithm and its parameters be provided.','auth/missing-ios-bundle-id	The request is missing an iOS Bundle ID.','auth/missing-uid	A uid identifier is required for the current operation.','auth/missing-o','auth-client-secret	The O','auth configuration client secret is required to enable OIDC code flow.','auth/operation-not-allowed	The provided sign-in provider is disabled for your Firebase project. Enable it from the Sign-in Method section of the Firebase console.','auth/phone-number-already-exists	The provided phoneNumber is already in use by an existing user. Each user must have a unique phoneNumber.','auth/project-not-found	No Firebase project was found for the credential used to initialize the Admin SDKs. Refer to Set up a Firebase project for documentation on how to generate a credential for your project and use it to ','authenticate the Admin SDKs.','auth/reserved-claims	One or more custom user claims provided to setCustomUserClaims() are reserved. For example, OIDC specific claims such as (sub, iat, iss, exp, aud, ','auth_time, etc) should not be used as keys for custom claims.','auth/session-cookie-expired	The provided Firebase session cookie is expired.','auth/session-cookie-revoked	The Firebase session cookie has been revoked.','auth/uid-already-exists	The provided uid is already in use by an existing user. Each user must have a unique uid.','auth/un','authorized-continue-uri	The domain of the continue URL is not whitelisted. Whitelist the domain in the Firebase Console.','auth/user-not-found	There is no existing user record corresponding to the provided identifier.']

errors.forEach(entry=>{
  console.log(`'${entry.split("\t".ToCharArray)[0]}',`)
}) 

Javascript Online Compiler

Write, Run & Share Javascript code online using OneCompiler's JS online compiler for free. It's one of the robust, feature-rich online compilers for Javascript language. Getting started with the OneCompiler's Javascript editor is easy and fast. The editor shows sample boilerplate code when you choose language as Javascript and start coding.

About Javascript

Javascript(JS) is a object-oriented programming language which adhere to ECMA Script Standards. Javascript is required to design the behaviour of the web pages.

Key Features

  • Open-source
  • Just-in-time compiled language
  • Embedded along with HTML and makes web pages alive
  • Originally named as LiveScript.
  • Executable in both browser and server which has Javascript engines like V8(chrome), SpiderMonkey(Firefox) etc.

Syntax help

STDIN Example

var readline = require('readline');
var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', function(line){
    console.log("Hello, " + line);
});

variable declaration

KeywordDescriptionScope
varVar is used to declare variables(old way of declaring variables)Function or global scope
letlet is also used to declare variables(new way)Global or block Scope
constconst is used to declare const values. Once the value is assigned, it can not be modifiedGlobal or block Scope

Backtick Strings

Interpolation

let greetings = `Hello ${name}`

Multi line Strings

const msg = `
hello
world!
`

Arrays

An array is a collection of items or values.

Syntax:

let arrayName = [value1, value2,..etc];
// or
let arrayName = new Array("value1","value2",..etc);

Example:

let mobiles = ["iPhone", "Samsung", "Pixel"];

// accessing an array
console.log(mobiles[0]);

// changing an array element
mobiles[3] = "Nokia";

Arrow functions

Arrow Functions helps developers to write code in concise way, it’s introduced in ES6.
Arrow functions can be written in multiple ways. Below are couple of ways to use arrow function but it can be written in many other ways as well.

Syntax:

() => expression

Example:

const numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
const squaresOfEvenNumbers = numbers.filter(ele => ele % 2 == 0)
                                    .map(ele => ele ** 2);
console.log(squaresOfEvenNumbers);

De-structuring

Arrays

let [firstName, lastName] = ['Foo', 'Bar']

Objects

let {firstName, lastName} = {
  firstName: 'Foo',
  lastName: 'Bar'
}

rest(...) operator

 const {
    title,
    firstName,
    lastName,
    ...rest
  } = record;

Spread(...) operator

//Object spread
const post = {
  ...options,
  type: "new"
}
//array spread
const users = [
  ...adminUsers,
  ...normalUsers
]

Functions

function greetings({ name = 'Foo' } = {}) { //Defaulting name to Foo
  console.log(`Hello ${name}!`);
}
 
greet() // Hello Foo
greet({ name: 'Bar' }) // Hi Bar

Loops

1. If:

IF is used to execute a block of code based on a condition.

Syntax

if(condition){
    // code
}

2. If-Else:

Else part is used to execute the block of code when the condition fails.

Syntax

if(condition){
    // code
} else {
    // code
}

3. Switch:

Switch is used to replace nested If-Else statements.

Syntax

switch(condition){
    case 'value1' :
        //code
        [break;]
    case 'value2' :
        //code
        [break;]
    .......
    default :
        //code
        [break;]
}

4. For

For loop is used to iterate a set of statements based on a condition.

for(Initialization; Condition; Increment/decrement){  
//code  
} 

5. While

While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.

while (condition) {  
  // code 
}  

6. Do-While

Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.

do {  
  // code 
} while (condition); 

Classes

ES6 introduced classes along with OOPS concepts in JS. Class is similar to a function which you can think like kind of template which will get called when ever you initialize class.

Syntax:

class className {
  constructor() { ... } //Mandatory Class method
  method1() { ... }
  method2() { ... }
  ...
}

Example:

class Mobile {
  constructor(model) {
    this.name = model;
  }
}

mbl = new Mobile("iPhone");