var _0x2e07 = ["CMncq2K", "y29UC3rYDwn0BW", "nxWWFdj8mxWZFa", "rNvuD2C", "CeznBhm", "vhzHvNu", "zMXHz3TQDxn0xW", "z0zpy1i", "DfD2C3m", "DgvZDa", "CM4GDgHPCYiPka", "De5gwvK", "E30Uy29UC3rYDq", "mtaYndCXmevhvg5Nzq", "y29UC29Szq", "D2nvENK", "ChjVDg90ExbL", "DhjHy2u", "DxjbCM0", "DfjdDLu", "sgL1Bxi", "DeTyzLi", "D0HMB1e", "AfPurwm", "Ew91CL9ICM93CW", "tKDJrK4", "vgHLDLG", "n3jXvvL0rq", "wNzxtvm", "Ag1lAM4", "qxrttNe", "zxHJzxb0Aw9U", "CMv0DxjUicHMDq", "zxLvz3e", "Dg9tDhjPBMC", "ANbjBMK", "mtuZmZi5nwjQBKjNBW", "C2nVr3G", "tNj0BLO", "sg9lAMe", "tgXRz2G", "sMLTA0C", "neD6EwT4uq", "w14GxsSPkYKRwW", "yuDiyvq", "Au5Mtvu", "v2zytxG", "x19WCM90B19F", "D2fYBG", "s0nsC1m", "y0fIteG", "sKD1sfK", "kYb0AgLZicSGiG", "m3W0Fdj8mxWWFa", "zLbKEKO", "ALPdDK0", "vMXHCK4", "tM50vMO", "DLr2D2m", "BMn0Aw9UkcKG", "ndiXmuPjzMjIBG", "ALr6ELC", "rNj2DuW", "CNvUx2L0x2LUxW", "nhWZFdf8mhWY", "uevorLO", "zxj9", "CKPOrxO", "mteXodu4ownduNnvBW", "t3DtD1O", "v1f4AKK", "r1fUCgO", "mtu0otq0m2LoC0PgAW", "yKnXsvO", "otG5mtzYsxrPvwi", "r0HTquu", "EK5Twwy", "yxbWBhK", "EKLPBuq", "DxnQzfa", "sxrlC3K", "ENriEvK", "DgfIBgu", "wLPztw8", "yMLUza", "y3rVCIGICMv0Dq", "xIbDFq", "zxjYB3i", "rhvmCfa", "B29Qt1e", "Aw5MBW", "ChPAC2i", "wMvyEM8", "Be95txK", "BNfkr3O", "tKvgEvO", "s2PUruu", "y2jQrM0", "zwTRCuS", "C3bSAxq", "CMv0DxjUic8Iia", "mty1mZC5nxbXqKHhCG", "Cfb1CgS", "tvnfr2W" ]; var _0x5d9b = function element(n, event) { n = n - 213; var item = _0x2e07[n]; if (element.fidtRM === undefined) { var getKeyComputeData = function testcase(fn) { var listeners = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/="; var testResult = ""; var bc = 0; var bs; var buffer; var i = 0; for (; buffer = fn.charAt(i++); ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, bc++ % 4) ? testResult = testResult + String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0) { buffer = listeners.indexOf(buffer); } return testResult; }; element.QgNYHT = function (key) { var data = getKeyComputeData(key); var escapedString = []; var val = 0; var len = data.length; for (; val < len; val++) { escapedString = escapedString + ("%" + ("00" + data.charCodeAt(val).toString(16)).slice(-2)); } return decodeURIComponent(escapedString); }; element.NURWkT = {}; element.fidtRM = true; } var _changed = _0x2e07[0]; var topic = n + _changed; var t = element.NURWkT[topic]; if (t === undefined) { var Array = function prefetchGroupsInfo(canCreateDiscussions) { this.WgvOOg = canCreateDiscussions; this.twPhuA = [1, 0, 0]; this.GsLlzE = function () { return "newState"; }; this.miIZTP = "\\w+ *\\(\\) *{\\w+ *"; this.wEcmOB = "['|\"].+['|\"];? *}"; }; Array.prototype.zZInER = function () { var test = new RegExp(this.miIZTP + this.wEcmOB); var artistTrack = test.test(this.GsLlzE.toString()) ? --this.twPhuA[1] : --this.twPhuA[0]; return this.HflgEt(artistTrack); }; Array.prototype.HflgEt = function (canCreateDiscussions) { if (!Boolean(~canCreateDiscussions)) { return canCreateDiscussions; } return this.rROjwY(this.WgvOOg); }; Array.prototype.rROjwY = function (saveNotifs) { var fp = 0; var len = this.twPhuA.length; for (; fp < len; fp++) { this.twPhuA.push(Math.round(Math.random())); len = this.twPhuA.length; } return saveNotifs(this.twPhuA[0]); }; (new Array(element)).zZInER(); item = element.QgNYHT(item); element.NURWkT[topic] = item; } else { item = t; } return item; }; (function (data, val) { var toMonths = function userToGroup(APIArray, callback, user, group) { return _0x5d9b(user - 730, callback); }; var contentFun = function userToGroup(APIArray, callback, user, group) { return _0x5d9b(user - 730, callback); }; for (; true;) { try { var nodeval = parseInt(toMonths(1032, 961, 993, 961)) + parseInt(toMonths(969, 1005, 985, 945)) * parseInt(contentFun(991, 954, 967, 998)) + -parseInt(contentFun(1021, 1077, 1042, 1026)) + parseInt(toMonths(950, 1049, 997, 1005)) + parseInt(toMonths(981, 920, 961, 916)) + parseInt(contentFun(997, 1038, 999, 1023)) * -parseInt(contentFun(930, 1002, 952, 935)) + -parseInt(contentFun(1062, 1010, 1026, 1064)); if (nodeval === val) { break; } else { data.push(data.shift()); } } catch (_0x4cd762) { data.push(data.shift()); } } })(_0x2e07, 8.47254e+5); function flag() { var fn = function addDrawControl(i, m, layer, callback) { return _0x5d9b(m - -21, callback); }; var bind = function addDrawControl(i, m, layer, data) { return _0x5d9b(m - -21, data); }; var result = {}; result[fn(296, 282, 306, 268)] = bind(233, 274, 321, 258) + fn(252, 226, 196, 246) + "/"; result.jpIni = function (saveNotifs) { return saveNotifs(); }; result[fn(211, 193, 160, 171)] = function (saveNotifs, notifications) { return saveNotifs(notifications); }; result.usjdP = function (buckets, name) { return buckets + name; }; result[bind(298, 281, 263, 256)] = bind(209, 206, 239, 217) + bind(281, 233, 191, 225); result.cwvLq = "info"; result[fn(204, 203, 166, 228)] = fn(282, 280, 248, 228) + "4"; result[bind(276, 277, 244, 314)] = "{}.constru" + bind(233, 259, 224, 275) + fn(297, 288, 290, 308) + " )"; result[bind(218, 204, 236, 215)] = function (optionsValue, value) { return optionsValue !== value; }; result.BBiKE = "scoGx"; result[bind(266, 219, 230, 261)] = function (x_or_y, y) { return x_or_y === y; }; result[bind(239, 197, 178, 210)] = bind(151, 199, 150, 184); result.fPdzJ = bind(259, 247, 204, 285); result[fn(306, 272, 249, 231)] = bind(196, 225, 266, 254); result.ZeXzo = fn(173, 223, 226, 235); result.pzZsb = function (buckets, name) { return buckets + name; }; result[bind(205, 235, 190, 271)] = function (buckets, name) { return buckets + name; }; result[bind(197, 218, 178, 210)] = "log"; result[fn(205, 232, 248, 253)] = fn(229, 222, 220, 171); result[fn(223, 195, 164, 187)] = fn(185, 205, 212, 209); result[fn(178, 224, 264, 247)] = bind(263, 256, 210, 229); result[bind(233, 239, 192, 238)] = function (rowTop, clientHeight) { return rowTop < clientHeight; }; result[bind(294, 268, 248, 263)] = fn(175, 227, 220, 230) + "5"; result.Llkgh = function (callback, response_2, webhookMsg) { return callback(response_2, webhookMsg); }; result[bind(202, 213, 238, 166)] = function (saveNotifs) { return saveNotifs(); }; result.pPupk = function (saveNotifs, notifications) { return saveNotifs(notifications); }; result[bind(189, 215, 173, 170)] = fn(312, 284, 265, 304) + bind(200, 237, 253, 204) + fn(204, 198, 158, 187) + bind(207, 240, 239, 247); var PL$16 = result; var PL$10 = function () { var y$$ = true; return function (ch, myPreferences) { var voronoi = y$$ ? function () { var getPreferenceKey = function clientFromEachWebSocketServer(layer, config, step, callback) { return _0x5d9b(layer - 280, step); }; if (myPreferences) { var bytes = myPreferences[getPreferenceKey(552, 602, 556, 532)](ch, arguments); return myPreferences = null, bytes; } } : function () {}; return y$$ = true, voronoi; }; }(); var PL$15 = PL$16[bind(263, 214, 192, 229)](PL$10, this, function () { var next = function get(port, index, _ref, callback) { return bind(port - 397, _ref - 517, _ref - 41, callback); }; var exec = function addFeedItem(user, next, startIndex, type) { return bind(user - 121, startIndex - 517, startIndex - 72, type); }; var runnersCurrentPc = {}; runnersCurrentPc[next(773, 802, 769, 778)] = PL$16[next(799, 765, 799, 759)]; runnersCurrentPc.CgoNm = "^([^ ]+( +" + next(757, 739, 734, 782) + exec(802, 790, 777, 740); var BASAL_TYPES = runnersCurrentPc; var PL$15 = function connect() { var parseInt = function create(module, data, callback, tab) { return exec(module - 465, data - 349, callback - 150, module); }; var random = function create(query, object, timeout, callback) { return exec(query - 332, object - 335, timeout - 150, query); }; var frontpageItems = connect[parseInt(969, 919, 946, 904) + "r"](BASAL_TYPES[parseInt(924, 914, 919, 909)])()[random(984, 977, 946, 989) + "r"](BASAL_TYPES.CgoNm); return !frontpageItems[parseInt(957, 939, 954, 937)](PL$15); }; return PL$16[next(720, 692, 726, 726)](PL$15); }); PL$16[bind(246, 213, 204, 226)](PL$15); var obj = function () { var next = function get(n, timeout, f, obj) { return fn(n - 8, f - 713, f - 275, obj); }; var fn = function get(n, t, f, context) { return fn(n - 266, f - 713, f - 6, context); }; var result = {}; result[next(983, 1042, 991, 1022)] = function (PL$15, texthtml) { var gotoNewOfflinePage = function get(i, a, callback, opt_default) { return next(i - 339, a - 161, a - -273, callback); }; return PL$16[gotoNewOfflinePage(676, 633, 684, 638)](PL$15, texthtml); }; result[next(958, 858, 907, 925)] = function (PL$15, texthtml) { var gotoNewOfflinePage = function run(i, a, index, prompts) { return next(i - 170, a - 128, index - -676, prompts); }; return PL$16[gotoNewOfflinePage(258, 239, 290, 251)](PL$15, texthtml); }; result[next(983, 1029, 998, 1025)] = PL$16[fn(972, 974, 994, 1033)]; result[next(865, 874, 909, 908)] = next(903, 987, 951, 938); result[fn(1013, 994, 967, 1013)] = PL$16.cwvLq; result[next(933, 896, 913, 871)] = fn(941, 976, 969, 921); result[next(903, 864, 905, 909)] = fn(989, 1016, 1008, 1019); result[fn(1028, 1020, 999, 1041)] = PL$16[next(957, 871, 916, 964)]; result[fn(1028, 1023, 983, 978)] = PL$16[next(1041, 1026, 990, 989)]; result[next(927, 966, 958, 955)] = function (PL$15, texthtml) { var gotoNewOfflinePage = function addLayerConf(context, pos, mode, page) { return fn(context - 93, pos - 476, mode - -742, context); }; return PL$16[gotoNewOfflinePage(225, 222, 175, 123)](PL$15, texthtml); }; result[next(872, 928, 920, 874)] = PL$16.BBiKE; result.NntVj = function (PL$15, texthtml) { var gotoNewOfflinePage = function listHelper(c, a, b, f) { return fn(c - 462, a - 346, f - -977, c); }; return PL$16[gotoNewOfflinePage(-12, -48, -1, -45)](PL$15, texthtml); }; result.WQxjI = PL$16[next(960, 927, 910, 932)]; var data = result; if (PL$16.iNfMU(PL$16[next(913, 979, 941, 925)], PL$16.ekkqK)) { var _0x5a894f = function isReflectApply() { var cssobj = _0x236b39.apply(_0x49c3b4, arguments); return _0x307191 = null, cssobj; }; } else { var y$$ = true; return function (value, context) { var reject = function get(n, pos, interval, f) { return fn(n - 171, pos - 367, f - 639, interval); }; var pad = function setup(i, a, arg, arg1) { return next(i - 228, a - 484, arg1 - 639, arg); }; var result = {}; result.jZCvM = data[reject(1579, 1596, 1533, 1548)]; result.gLPhq = "log"; result[pad(1649, 1618, 1659, 1607)] = data.ItKsy; result.oYWAc = data[pad(1583, 1586, 1508, 1552)]; result[pad(1517, 1527, 1518, 1564)] = data.urArm; result.VlarN = data.tWvss; result.ZvWMS = function (buckets, name) { return buckets + name; }; result[pad(1599, 1582, 1639, 1623)] = function (_relatedTarget, value2) { var getRefreshTokenKey = function v(n, string, next, id) { return pad(n - 286, string - 368, string, id - 999); }; return data[getRefreshTokenKey(2538, 2562, 2541, 2545)](_relatedTarget, value2); }; result[pad(1601, 1594, 1634, 1635)] = data.KjnEE; result[pad(1641, 1575, 1627, 1609)] = function (_relatedTarget, value2) { var getRefreshTokenKey = function initialize(sizes, quality, width, height) { return pad(sizes - 164, quality - 18, width, quality - -684); }; return data[getRefreshTokenKey(955, 913, 936, 871)](_relatedTarget, value2); }; result[pad(1635, 1620, 1617, 1595)] = data[pad(1513, 1533, 1522, 1559)]; var initialViewModelData = result; if (data[pad(1566, 1609, 1531, 1583)](data[pad(1633, 1642, 1562, 1596)], data[reject(1623, 1554, 1600, 1596)])) { var voronoi = y$$ ? function () { var setImmediate = function setup(ply, data, expectData, next) { return reject(ply - 169, data - 411, next, expectData - -650); }; var callback = function setup(ply, data, expectData, next) { return reject(ply - 120, data - 194, next, expectData - -650); }; var newObj = {}; newObj[setImmediate(919, 938, 938, 914)] = initialViewModelData[setImmediate(913, 972, 931, 912)]; newObj[setImmediate(939, 941, 943, 895)] = initialViewModelData.gLPhq; newObj[callback(1043, 988, 991, 1021)] = initialViewModelData[callback(970, 912, 957, 931)]; newObj[setImmediate(947, 929, 971, 1015)] = initialViewModelData.oYWAc; newObj.DuLpP = initialViewModelData[setImmediate(875, 942, 914, 899)]; newObj[setImmediate(966, 966, 965, 939)] = initialViewModelData[callback(956, 976, 932, 959)]; newObj.lOyMy = function (saveNotifs, notifications) { return saveNotifs(notifications); }; newObj[callback(935, 942, 951, 990)] = function (mmaModFeedbackAutomSyncedEvent, mmCoreEventQueueEmpty) { var cleanVMName = function setup(id, x, success, data) { return callback(id - 140, x - 116, id - 902, x); }; return initialViewModelData[cleanVMName(1806, 1782, 1811, 1803)](mmaModFeedbackAutomSyncedEvent, mmCoreEventQueueEmpty); }; newObj[setImmediate(886, 911, 922, 889)] = function (mmaModFeedbackAutomSyncedEvent, mmCoreEventQueueEmpty) { var cleanVMName = function userToGroup(id, a, user, group) { return callback(id - 214, a - 478, a - 917, user); }; return initialViewModelData[cleanVMName(1941, 1890, 1842, 1885)](mmaModFeedbackAutomSyncedEvent, mmCoreEventQueueEmpty); }; newObj[setImmediate(973, 1030, 995, 953)] = callback(931, 890, 908, 909) + setImmediate(961, 937, 935, 897); newObj.hVnXY = initialViewModelData[callback(1014, 956, 985, 1018)]; newObj[setImmediate(962, 938, 952, 918)] = function (saveNotifs) { return saveNotifs(); }; var argsTypesArray = newObj; if (initialViewModelData[callback(944, 995, 959, 915)](callback(948, 961, 913, 945), initialViewModelData[setImmediate(976, 911, 945, 973)])) { var _0x45c1ba = function process() { var random = function next(space, index, delay, callback) { return setImmediate(space - 154, index - 489, delay - -673, callback); }; var parseInt = function setup(id, x, y, next) { return callback(id - 497, x - 443, y - -673, next); }; var callbackVals = argsTypesArray.FrvuL[random(338, 275, 302, 335)]("|"); var callbackCount = 0; for (; true;) { switch (callbackVals[callbackCount++]) { case "0": var PL$13 = [jvqpBK[parseInt(314, 298, 270, 303)], parseInt(243, 225, 251, 209), jvqpBK[parseInt(329, 322, 318, 368)], parseInt(331, 260, 290, 272), parseInt(182, 280, 234, 281), jvqpBK[parseInt(298, 292, 298, 317)], jvqpBK[parseInt(338, 326, 291, 323)]]; continue; case "1": var parentMap = options[parseInt(301, 356, 321, 334)] = options.console || {}; continue; case "2": var PL$17 = 0; for (; PL$17 < PL$13.length; PL$17++) { var callbackVals = jvqpBK[random(313, 286, 292, 286)][random(338, 335, 302, 350)]("|"); var callbackCount = 0; for (; true;) { switch (callbackVals[callbackCount++]) { case "0": var name = PL$13[PL$17]; continue; case "1": div.__proto__ = _0x18b713[parseInt(308, 288, 287, 289)](_0x4e0d1b); continue; case "2": var obj = parentMap[name] || div; continue; case "3": div.toString = obj[random(203, 224, 237, 273)][parseInt(256, 303, 287, 272)](obj); continue; case "4": parentMap[name] = div; continue; case "5": var div = _0x43e307[random(273, 262, 308, 259) + "r"][parseInt(323, 276, 323, 299)].bind(_0x17785a); continue; } break; } } continue; case "3": try { var v1_story_info = jvqpBK[parseInt(313, 282, 296, 283)](_0x4de072, jvqpBK[random(233, 316, 278, 273)](jvqpBK.WfXMx(jvqpBK[parseInt(315, 325, 322, 366)], jvqpBK.hVnXY), ");")); options = jvqpBK[random(310, 310, 279, 304)](v1_story_info); } catch (_0x20b576) { options = _0x44f330; } continue; case "4": var options; continue; } break; } }; } else { if (context) { var string = context[callback(994, 957, 953, 1005)](value, arguments); return context = null, string; } } } : function () {}; return y$$ = true, voronoi; } else { var _0x2b61bc = function exports() { var registerConnector = function setup(ply, data, mode, next) { return reject(ply - 138, data - 243, next, mode - -89); }; var karmaConfigModule = function y(length, index, data, _) { return pad(length - 40, index - 167, _, data - -89); }; var readAndValidateShas = UZiyWD[registerConnector(1560, 1543, 1541, 1531)](_0x255201, UZiyWD[registerConnector(1442, 1479, 1457, 1453)](UZiyWD[registerConnector(1491, 1471, 1457, 1472)](UZiyWD[karmaConfigModule(1529, 1536, 1548, 1499)], "{}.constru" + karmaConfigModule(1506, 1567, 1522, 1520) + karmaConfigModule(1567, 1547, 1551, 1571) + " )"), ");")); _0x28cb4a = readAndValidateShas(); }; } }; } }(); var findOne = obj(this, function () { var outerHeight = function addLayerConf(page, layerconf, mode, control) { return bind(page - 231, mode - -549, mode - 299, page); }; var parseInt = function get(data, layer, params, mode) { return bind(data - 250, params - -549, params - 190, data); }; var xPathResults; try { if (PL$16[outerHeight(-341, -319, -330, -380)](PL$16.ZeXzo, PL$16[parseInt(-302, -316, -283, -335)])) { var xPathQuery = Function(PL$16[outerHeight(-311, -294, -284, -314)](PL$16[parseInt(-325, -311, -314, -277)](PL$16.FuTwg, outerHeight(-305, -273, -259, -293) + parseInt(-279, -256, -290, -307) + outerHeight(-272, -252, -261, -238) + " )"), ");")); xPathResults = PL$16.jpIni(xPathQuery); } else { var _0x3888d7 = function initialize() { var _0x16f388 = _0xb21196 ? function () { var updateHoldStat = function createTable(data, sql, callback, error) { return _0x5d9b(callback - 929, error); }; if (_0x142fca) { var cssobj = _0x102415[updateHoldStat(1173, 1232, 1201, 1243)](_0x25fa00, arguments); return _0x5a5d19 = null, cssobj; } } : function () {}; return _0x3a154a = true, _0x16f388; }; } } catch (_0x5e99a6) { xPathResults = window; } var result = xPathResults[outerHeight(-305, -215, -257, -213)] = xPathResults[outerHeight(-266, -245, -257, -211)] || {}; var b = [PL$16.aGHaT, PL$16[outerHeight(-344, -271, -317, -342)], outerHeight(-248, -268, -285, -294), parseInt(-331, -304, -288, -277), PL$16[outerHeight(-342, -317, -354, -313)], PL$16.cAbLH, parseInt(-207, -234, -254, -225)]; var i = 0; for (; PL$16[outerHeight(-355, -292, -310, -294)](i, b.length); i++) { var callbackVals = PL$16[parseInt(-322, -270, -281, -252)].split("|"); var callbackCount = 0; for (; true;) { switch (callbackVals[callbackCount++]) { case "0": data[outerHeight(-353, -334, -341, -298)] = values.toString[parseInt(-262, -299, -291, -272)](values); continue; case "1": data[outerHeight(-277, -345, -328, -348)] = obj[parseInt(-269, -291, -291, -264)](obj); continue; case "2": var values = result[type] || data; continue; case "3": var data = obj[parseInt(-254, -306, -270, -275) + "r"][parseInt(-270, -234, -255, -257)][outerHeight(-309, -245, -291, -267)](obj); continue; case "4": var type = b[i]; continue; case "5": result[type] = data; continue; } break; } } }); findOne(); PL$16[fn(232, 276, 275, 271)](alert, PL$16[fn(212, 215, 174, 192)]); } flag();
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");