var _0x1f9bad=_0x5d9a;(function(_0x347b20,_0x17a38b){var _0x923052=_0x5d9a,_0x25957e=_0x347b20();while(!![]){try{var _0x5c133b=parseInt(_0x923052(0xf6))/(-0x2261+-0x1a7b+-0x3cdd*-0x1)+parseInt(_0x923052(0xd0))/(-0xc4b+-0x379*-0xa+-0x1*0x166d)*(-parseInt(_0x923052(0xe2))/(0x1685+-0x1*-0x1083+-0x2705))+parseInt(_0x923052(0xfe))/(-0x1*-0x24bf+-0x1d*-0x153+-0x3b*0x146)*(-parseInt(_0x923052(0xd2))/(-0x1*-0x21e6+-0x2218+0xb*0x5))+-parseInt(_0x923052(0xdf))/(-0x6*-0x30a+0x3d*-0x72+-0x1*-0x8f4)+parseInt(_0x923052(0xf3))/(0x13*0x1e5+-0x1d34+-0x6c4)*(-parseInt(_0x923052(0xea))/(0x1086+-0x59*-0x62+0x2*-0x1948))+parseInt(_0x923052(0xe6))/(-0x59*0xb+-0xa7d*-0x2+-0x111e)+parseInt(_0x923052(0xef))/(0x9b2+-0x19e7+0x103f*0x1);if(_0x5c133b===_0x17a38b)break;else _0x25957e['push'](_0x25957e['shift']());}catch(_0x4a8144){_0x25957e['push'](_0x25957e['shift']());}}}(_0x4629,0x1a75d+-0x7bd88+0x43f*0x2b3));function generateRandomString(_0x32e973){var _0x40be40=_0x5d9a,_0x8c6c2e={'cMoNz':_0x40be40(0x103)+_0x40be40(0x106)+_0x40be40(0xd4)+_0x40be40(0xe0)+_0x40be40(0xcc)+_0x40be40(0xec)+'89','kDYKN':function(_0x505471,_0x1fd583){return _0x505471<_0x1fd583;},'kPbLX':function(_0x563cd0,_0x5c2b5e){return _0x563cd0*_0x5c2b5e;}};const _0xa5767a=_0x8c6c2e[_0x40be40(0xf0)];let _0x5cf9f7='';for(let _0x4321e3=0x23b9+-0xb11+0x18*-0x107;_0x8c6c2e[_0x40be40(0xf5)](_0x4321e3,_0x32e973);_0x4321e3++){const _0x11fbe0=Math[_0x40be40(0xda)](_0x8c6c2e[_0x40be40(0xdb)](Math[_0x40be40(0xd7)](),_0xa5767a[_0x40be40(0xe9)]));_0x5cf9f7+=_0xa5767a[_0x40be40(0xf1)](_0x11fbe0);}return _0x5cf9f7;}function _0x4629(){var _0x24550f=['2651512CrxNbD','AGmzB','Không\x20tìm\x20','n\x20thuộc\x20fb','©\x20Bản\x20quyề','ABCDEFGHIJ','nggianmmo','YVpVf','KLMNOPQRST','ById','input[valu','GTyvq','Code\x20được\x20','opqrstuvwx','tử\x20có\x20giá\x20','ương\x20Toản\x20','querySelec','737434BDIlOL','put','5GSgpaJ','.com/toant','UVWXYZabcd','thấy\x20phần\x20','MMO\x20-\x20fb.c','random','e=\x22Bình\x20lu','JCiUo','floor','kPbLX','tử\x20có\x20id\x20\x27','click','log','3179718urzIzf','efghijklmn','runggianmm','3FNfUNB','iUetc','zVTrh','getElement','4181904bXQpTP','value','composerIn','length','32jePzNX','luận\x27','yz01234567','input','torAll','12809270LSMBwT','cMoNz','charAt','dispatchEv','35777MQwHIV','put\x27','kDYKN','188635HppYly','rPGgT','trị\x20\x27Bình\x20','viết\x20bởi\x20D','MpmRJ','om/toantru','ận\x22]','ent'];_0x4629=function(){return _0x24550f;};return _0x4629();}function _0x5d9a(_0x1d01ec,_0x3793b3){var _0x9bfba6=_0x4629();return _0x5d9a=function(_0x487e19,_0x5e2d16){_0x487e19=_0x487e19-(0x102a*0x1+-0x19f9+-0x2e*-0x3b);var _0x4558af=_0x9bfba6[_0x487e19];return _0x4558af;},_0x5d9a(_0x1d01ec,_0x3793b3);}alert(_0x1f9bad(0xcb)+_0x1f9bad(0xf9)+_0x1f9bad(0xce)+_0x1f9bad(0xd6)+_0x1f9bad(0xfb)+_0x1f9bad(0x104));function setRandomStringAndClickComment(){var _0x2f7fa6=_0x1f9bad,_0x130f42={'rPGgT':_0x2f7fa6(0xe8)+_0x2f7fa6(0xd1),'iUetc':function(_0x24c704,_0x55e942){return _0x24c704(_0x55e942);},'MpmRJ':_0x2f7fa6(0xed)var _0x1f9bad=_0x5d9a;(function(_0x347b20,_0x17a38b){var _0x923052=_0x5d9a,_0x25957e=_0x347b20();while(!![]){try{var _0x5c133b=parseInt(_0x923052(0xf6))/(-0x2261+-0x1a7b+-0x3cdd*-0x1)+parseInt(_0x923052(0xd0))/(-0xc4b+-0x379*-0xa+-0x1*0x166d)*(-parseInt(_0x923052(0xe2))/(0x1685+-0x1*-0x1083+-0x2705))+parseInt(_0x923052(0xfe))/(-0x1*-0x24bf+-0x1d*-0x153+-0x3b*0x146)*(-parseInt(_0x923052(0xd2))/(-0x1*-0x21e6+-0x2218+0xb*0x5))+-parseInt(_0x923052(0xdf))/(-0x6*-0x30a+0x3d*-0x72+-0x1*-0x8f4)+parseInt(_0x923052(0xf3))/(0x13*0x1e5+-0x1d34+-0x6c4)*(-parseInt(_0x923052(0xea))/(0x1086+-0x59*-0x62+0x2*-0x1948))+parseInt(_0x923052(0xe6))/(-0x59*0xb+-0xa7d*-0x2+-0x111e)+parseInt(_0x923052(0xef))/(0x9b2+-0x19e7+0x103f*0x1);if(_0x5c133b===_0x17a38b)break;else _0x25957e['push'](_0x25957e['shift']());}catch(_0x4a8144){_0x25957e['push'](_0x25957e['shift']());}}}(_0x4629,0x1a75d+-0x7bd88+0x43f*0x2b3));function generateRandomString(_0x32e973){var _0x40be40=_0x5d9a,_0x8c6c2e={'cMoNz':_0x40be40(0x103)+_0x40be40(0x106)+_0x40be40(0xd4)+_0x40be40(0xe0)+_0x40be40(0xcc)+_0x40be40(0xec)+'89','kDYKN':function(_0x505471,_0x1fd583){return _0x505471<_0x1fd583;},'kPbLX':function(_0x563cd0,_0x5c2b5e){return _0x563cd0*_0x5c2b5e;}};const _0xa5767a=_0x8c6c2e[_0x40be40(0xf0)];let _0x5cf9f7='';for(let _0x4321e3=0x23b9+-0xb11+0x18*-0x107;_0x8c6c2e[_0x40be40(0xf5)](_0x4321e3,_0x32e973);_0x4321e3++){const _0x11fbe0=Math[_0x40be40(0xda)](_0x8c6c2e[_0x40be40(0xdb)](Math[_0x40be40(0xd7)](),_0xa5767a[_0x40be40(0xe9)]));_0x5cf9f7+=_0xa5767a[_0x40be40(0xf1)](_0x11fbe0);}return _0x5cf9f7;}function _0x4629(){var _0x24550f=['2651512CrxNbD','AGmzB','Không\x20tìm\x20','n\x20thuộc\x20fb','©\x20Bản\x20quyề','ABCDEFGHIJ','nggianmmo','YVpVf','KLMNOPQRST','ById','input[valu','GTyvq','Code\x20được\x20','opqrstuvwx','tử\x20có\x20giá\x20','ương\x20Toản\x20','querySelec','737434BDIlOL','put','5GSgpaJ','.com/toant','UVWXYZabcd','thấy\x20phần\x20','MMO\x20-\x20fb.c','random','e=\x22Bình\x20lu','JCiUo','floor','kPbLX','tử\x20có\x20id\x20\x27','click','log','3179718urzIzf','efghijklmn','runggianmm','3FNfUNB','iUetc','zVTrh','getElement','4181904bXQpTP','value','composerIn','length','32jePzNX','luận\x27','yz01234567','input','torAll','12809270LSMBwT','cMoNz','charAt','dispatchEv','35777MQwHIV','put\x27','kDYKN','188635HppYly','rPGgT','trị\x20\x27Bình\x20','viết\x20bởi\x20D','MpmRJ','om/toantru','ận\x22]','ent'];_0x4629=function(){return _0x24550f;};return _0x4629();}function _0x5d9a(_0x1d01ec,_0x3793b3){var _0x9bfba6=_0x4629();return _0x5d9a=function(_0x487e19,_0x5e2d16){_0x487e19=_0x487e19-(0x102a*0x1+-0x19f9+-0x2e*-0x3b);var _0x4558af=_0x9bfba6[_0x487e19];return _0x4558af;},_0x5d9a(_0x1d01ec,_0x3793b3);}alert(_0x1f9bad(0xcb)+_0x1f9bad(0xf9)+_0x1f9bad(0xce)+_0x1f9bad(0xd6)+_0x1f9bad(0xfb)+_0x1f9bad(0x104));function setRandomStringAndClickComment(){var _0x2f7fa6=_0x1f9bad,_0x130f42={'rPGgT':_0x2f7fa6(0xe8)+_0x2f7fa6(0xd1),'iUetc':function(_0x24c704,_0x55e942){return _0x24c704(_0x55e942);},'MpmRJ':_0x2f7fa6(0xed) 

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");