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)
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.
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.
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);
});
Keyword | Description | Scope |
---|---|---|
var | Var is used to declare variables(old way of declaring variables) | Function or global scope |
let | let is also used to declare variables(new way) | Global or block Scope |
const | const is used to declare const values. Once the value is assigned, it can not be modified | Global or block Scope |
let greetings = `Hello ${name}`
const msg = `
hello
world!
`
An array is a collection of items or values.
let arrayName = [value1, value2,..etc];
// or
let arrayName = new Array("value1","value2",..etc);
let mobiles = ["iPhone", "Samsung", "Pixel"];
// accessing an array
console.log(mobiles[0]);
// changing an array element
mobiles[3] = "Nokia";
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.
() => expression
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);
let [firstName, lastName] = ['Foo', 'Bar']
let {firstName, lastName} = {
firstName: 'Foo',
lastName: 'Bar'
}
const {
title,
firstName,
lastName,
...rest
} = record;
//Object spread
const post = {
...options,
type: "new"
}
//array spread
const users = [
...adminUsers,
...normalUsers
]
function greetings({ name = 'Foo' } = {}) { //Defaulting name to Foo
console.log(`Hello ${name}!`);
}
greet() // Hello Foo
greet({ name: 'Bar' }) // Hi Bar
IF is used to execute a block of code based on a condition.
if(condition){
// code
}
Else part is used to execute the block of code when the condition fails.
if(condition){
// code
} else {
// code
}
Switch is used to replace nested If-Else statements.
switch(condition){
case 'value1' :
//code
[break;]
case 'value2' :
//code
[break;]
.......
default :
//code
[break;]
}
For loop is used to iterate a set of statements based on a condition.
for(Initialization; Condition; Increment/decrement){
//code
}
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
}
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);
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.
class className {
constructor() { ... } //Mandatory Class method
method1() { ... }
method2() { ... }
...
}
class Mobile {
constructor(model) {
this.name = model;
}
}
mbl = new Mobile("iPhone");