function test() { `const _0x4a4b = ['queryNumericAttribute', 'nodeValue', 'length', 'test', 'substring', 'childNodes', 'getAttributeNodeNS', 'queryFirstNode', 'getElementsByTagName', 'getAttribute', '93894zmrrUY', 'xmldom', '163255MGrgGa', '15601nDEBaF', 'attributes', '19QfiloH', 'indexOf', 'textContent', 'localName', 'getElementsByTagNameNS', 'firstChild', 'loadXML', 'push', 'text/xml', 'queryBooleanAttribute', 'parseFromString', 'getChildValue', 'prefix', 'true', '47nsVDUB', '1563086SZZjXo', 'namespaceURI', 'queryStringAttribute', 'trim', 'nextSibling', '12319OBtRUE', 'false', '172638QuEzMt', '75273xTtfPV', 'nodeName']; function _0x1682(_0x1377aa, _0x206bd2) { _0x1377aa = _0x1377aa - 0xca; let _0x4a4bd8 = _0x4a4b[_0x1377aa]; return _0x4a4bd8; } const _0x4cb7e1 = _0x1682; (function (_0x24e8ac, _0x1dd8b6) { const _0x4a7826 = _0x1682; while (!![]) { try { const _0x44f2d8 = parseInt(_0x4a7826(0xd0)) * -parseInt(_0x4a7826(0xca)) + parseInt(_0x4a7826(0xe2)) * -parseInt(_0x4a7826(0xe4)) + parseInt(_0x4a7826(0xdf)) + -parseInt(_0x4a7826(0xd2)) + -parseInt(_0x4a7826(0xd3)) + -parseInt(_0x4a7826(0xe1)) + parseInt(_0x4a7826(0xcb)); if (_0x44f2d8 === _0x1dd8b6) break; else _0x24e8ac['push'](_0x24e8ac['shift']()); } catch (_0x5a776d) { _0x24e8ac['push'](_0x24e8ac['shift']()); } } }(_0x4a4b, 0x5a6e2)); function XMLParser() {} XMLParser['read'] = function (_0xfcaf23) { const _0x548950 = _0x1682; let _0x411708 = _0xfcaf23['indexOf']('<'); _0x411708 > 0x0 && (_0xfcaf23 = _0xfcaf23[_0x548950(0xd9)](_0x411708)); if (DOMParser) return !XMLParser[_0x548950(0xe0)] && (XMLParser[_0x548950(0xe0)] = new DOMParser()), XMLParser[_0x548950(0xe0)][_0x548950(0xee)](_0xfcaf23, _0x548950(0xec)); return !XMLParser[_0x548950(0xe0)] && (XMLParser[_0x548950(0xe0)] = new ActiveXObject('Microsoft.XMLDOM')), XMLParser[_0x548950(0xe0)][_0x548950(0xea)](_0xfcaf23); }, XMLParser[_0x4cb7e1(0xe8)] = function (_0xba417b, _0x4ce1c2, _0x52f972) { const _0x20b795 = _0x4cb7e1; let _0x543bb9 = []; if (_0xba417b['getElementsByTagNameNS']) _0x543bb9 = _0xba417b[_0x20b795(0xe8)](_0x4ce1c2, _0x52f972); else { let _0x5b3d04 = _0xba417b[_0x20b795(0xdd)]('*'), _0x375cc9, _0x1a99c6; for (let _0x47b6aa = 0x0, _0x42e0d8 = _0x5b3d04[_0x20b795(0xd7)]; _0x47b6aa < _0x42e0d8; ++_0x47b6aa) { _0x375cc9 = _0x5b3d04[_0x47b6aa], _0x1a99c6 = _0x375cc9[_0x20b795(0xf0)] ? _0x375cc9[_0x20b795(0xf0)] + ':' + _0x52f972 : _0x52f972, (_0x52f972 === '*' || _0x1a99c6 === _0x375cc9[_0x20b795(0xd4)]) && ((_0x4ce1c2 === '*' || _0x4ce1c2 === _0x375cc9[_0x20b795(0xcc)]) && _0x543bb9['push'](_0x375cc9)); } } return _0x543bb9; }, XMLParser[_0x4cb7e1(0xdb)] = function (_0x2a783f, _0x39ffd7, _0x1648e0) { const _0x5035d3 = _0x4cb7e1; let _0x25ed7b = null; if (_0x2a783f[_0x5035d3(0xdb)]) _0x25ed7b = _0x2a783f['getAttributeNodeNS'](_0x39ffd7, _0x1648e0); else { let _0x467932 = _0x2a783f[_0x5035d3(0xe3)], _0x552ed9, _0x54e3fe; for (let _0x32fad6 = 0x0, _0xc2c669 = _0x467932['length']; _0x32fad6 < _0xc2c669; ++_0x32fad6) { _0x552ed9 = _0x467932[_0x32fad6]; if (_0x552ed9['namespaceURI'] === _0x39ffd7) { _0x54e3fe = _0x552ed9[_0x5035d3(0xf0)] ? _0x552ed9[_0x5035d3(0xf0)] + ':' + _0x1648e0 : _0x1648e0; if (_0x54e3fe === _0x552ed9[_0x5035d3(0xd4)]) { _0x25ed7b = _0x552ed9; break; } } } } return _0x25ed7b; }, XMLParser[_0x4cb7e1(0xef)] = function (_0x4a056d, _0x4ef96f) { const _0x5dca3a = _0x4cb7e1; let _0x304127 = _0x4ef96f || ''; if (_0x4a056d) for (let _0x289d9c = _0x4a056d[_0x5dca3a(0xe9)]; _0x289d9c; _0x289d9c = _0x289d9c[_0x5dca3a(0xcf)]) { switch (_0x289d9c['nodeType']) { case 0x3: case 0x4: _0x304127 += _0x289d9c[_0x5dca3a(0xd6)]; } } return _0x304127; }, XMLParser[_0x4cb7e1(0xd5)] = function (_0x45e317, _0x1c9389) { if (!_0x45e317) return undefined; let _0x43409a = _0x45e317['getAttribute'](_0x1c9389); if (_0x43409a !== null) { let _0x4983cc = parseFloat(_0x43409a); return !isNaN(_0x4983cc) ? _0x4983cc : undefined; } return undefined; }, XMLParser[_0x4cb7e1(0xcd)] = function (_0xaa1d98, _0x2ec13a) { const _0x4020de = _0x4cb7e1; if (!_0xaa1d98) return undefined; let _0x41f857 = _0xaa1d98[_0x4020de(0xde)](_0x2ec13a); return _0x41f857 !== null ? _0x41f857 : undefined; }, XMLParser[_0x4cb7e1(0xed)] = function (_0x2a032f, _0x41f1b8) { const _0x204d39 = _0x4cb7e1; if (!_0x2a032f) return undefined; let _0x4376d1 = _0x2a032f[_0x204d39(0xde)](_0x41f1b8); _0x4376d1 = _0x4376d1['toLowerCase'](); if (_0x204d39(0xd1) === _0x4376d1) return ![]; if (_0x204d39(0xf1) === _0x4376d1) return !![]; return undefined; }, XMLParser['queryFirstNode'] = function (_0x4ed04a, _0x1fedb5, _0x5a0eb8) { const _0x38a1e4 = _0x4cb7e1; if (!_0x4ed04a) return undefined; let _0x22c5d8 = _0x4ed04a[_0x38a1e4(0xda)], _0x136c7b = _0x22c5d8[_0x38a1e4(0xd7)]; for (let _0x550837 = 0x0; _0x550837 < _0x136c7b; _0x550837++) { let _0x10469f = _0x22c5d8[_0x550837]; if (_0x5a0eb8) { if (_0x10469f[_0x38a1e4(0xe7)] === _0x1fedb5 && _0x5a0eb8[_0x38a1e4(0xe5)](_0x10469f[_0x38a1e4(0xcc)]) !== -0x1) return _0x10469f; } else { if (_0x10469f[_0x38a1e4(0xe7)] === _0x1fedb5) return _0x10469f; } } return undefined; }, XMLParser['queryNodes'] = function (_0x43ec38, _0x10bdc7, _0x397f6f) { const _0x285232 = _0x4cb7e1; if (!_0x43ec38) return undefined; let _0x183fdc = [], _0x1fd808 = _0x43ec38[_0x285232(0xe8)]('*', _0x10bdc7), _0x537023 = _0x1fd808[_0x285232(0xd7)]; for (let _0x7d044e = 0x0; _0x7d044e < _0x537023; _0x7d044e++) { let _0x397fe0 = _0x1fd808[_0x7d044e]; _0x397f6f ? _0x397fe0[_0x285232(0xe7)] === _0x10bdc7 && _0x397f6f[_0x285232(0xe5)](_0x397fe0[_0x285232(0xcc)]) !== -0x1 && _0x183fdc[_0x285232(0xeb)](_0x397fe0) : _0x397fe0['localName'] === _0x10bdc7 && _0x183fdc[_0x285232(0xeb)](_0x397fe0); } return _0x183fdc; }, XMLParser['queryChildNodes'] = function (_0x42fef9, _0x1113c3, _0x3fafe4) { const _0x853673 = _0x4cb7e1; if (!_0x42fef9) return []; let _0x4ce935 = [], _0x24c060 = _0x42fef9[_0x853673(0xda)], _0x1b6dfd = _0x24c060[_0x853673(0xd7)]; for (let _0x4e79a9 = 0x0; _0x4e79a9 < _0x1b6dfd; _0x4e79a9++) { let _0x527dea = _0x24c060[_0x4e79a9]; _0x3fafe4 ? _0x527dea[_0x853673(0xe7)] === _0x1113c3 && _0x3fafe4[_0x853673(0xe5)](_0x527dea[_0x853673(0xcc)]) !== -0x1 && _0x4ce935[_0x853673(0xeb)](_0x527dea) : _0x527dea[_0x853673(0xe7)] === _0x1113c3 && _0x4ce935[_0x853673(0xeb)](_0x527dea); } return _0x4ce935; }, XMLParser['queryNumericValue'] = function (_0xd92c35, _0x54bfd1, _0x496088) { let _0x2a5075 = XMLParser['queryFirstNode'](_0xd92c35, _0x54bfd1, _0x496088); if (_0x2a5075) { let _0x13b761 = parseFloat(_0x2a5075['textContent']); return !isNaN(_0x13b761) ? _0x13b761 : undefined; } return undefined; }, XMLParser['queryStringValue'] = function (_0x5f49a6, _0x518a55, _0x4485c6) { const _0x20231f = _0x4cb7e1; let _0x3abfc9 = XMLParser[_0x20231f(0xdc)](_0x5f49a6, _0x518a55, _0x4485c6); if (_0x3abfc9) return _0x3abfc9[_0x20231f(0xe6)][_0x20231f(0xce)](); return undefined; }, XMLParser['queryBooleanValue'] = function (_0x20e210, _0x3f6ac7, _0x1eb9ff) { const _0x96e043 = _0x4cb7e1; let _0x1b7a0b = XMLParser[_0x96e043(0xdc)](_0x20e210, _0x3f6ac7, _0x1eb9ff); if (_0x1b7a0b) { let _0x25df72 = _0x1b7a0b[_0x96e043(0xe6)][_0x96e043(0xce)](); return _0x25df72 === '1' || /^true$/i [_0x96e043(0xd8)](_0x25df72); } return undefined; };` } //test();
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");