Untitled

Run Settings
LanguageJavaScript
Language Version
Run Command
// //let a=[10,8,9,90,[20,10,30],90,100]; //let a=[10,8,9,90,[20,[10,10],30],90,100]; // let sum = 0; // function arySum(a){ // a.map((el,i)=>{ // if(typeof el == 'object'){ // arySum(el); // }else{ // if(typeof el == 'number') // sum += el; // } // }) // } // arySum(a); // console.log(sum); // function a(){ // for(var i=0;i<3;i++){ // setTimeout(function(i){ // return function(){ // console.log(i) // } // }(i),i*1000); // } // } // a(); // function flattened(a){ // let res = []; // a.map((el)=>{ // if(Array.isArray(el) && el.length > 0){ // res.push(...flattened(el)); // }else{ // res.push(el) // } // }); // return res; // } // console.log(flattened(a)); // let str='banana'; // let ary = str.split(""); // let res = {}; // ary.map((el)=>{ // let tmp = res[el]? res[el]:0; // res[el] = tmp+1; // }) // console.log(res); // function* test(){ // yield 'A'; // yield 'B'; // yield 'C'; // yield 'D'; // } // let x = test(); // const person = { name: "Lydia", age: 21 }; // const changeAge = (x = {...person}) => { // x.age += 1; // return x.age; // }; // const changeAgeAndName = (x = {...person}) => { // x.age += 1 // x.name = "Sarah" // }; // changeAge() // changeAgeAndName() // console.log(person) // function* range(start, end) { // for (i = start; i <= end; i++) { // yield i; // } // } // ( function(){ // let gen = range(1, 3); // for (item of gen) { // console.log(item); // } // })(); // let a = 1; // let b = a; // let c = "abc"; // let d = c; // let e = []; // let f = e; // let g = {a:1}; // let h = g; // c= c.replace("c","D"); // a = a+1; // e.push(3); // g.a = 2; // console.log(a,b,c,d,e,f,g,h) // const x = 'type'; // x.replace('y','d'); // x[1] = 'a'; // Nothing happens, doesn't throw an error // console.log(x); // LOGS: 'type' //var a=5; // if(true){ // console.log(a); // var a = 4; // } // (function(){ // console.log(a); // var a = 4; // })(); // let xyz = { // name:"kaushal", // fullname1: () =>{ // return "Shukla"+this.name; // }, // fullname2: function(){ // return "Shukla"+this.name; // } // } // console.log(xyz.fullname1()) // var obj = { // does not create a new scope // i: 10, // b: () => console.log(this.i, this), // c: function() { // console.log(this.i, this); // } // } // obj.b(); // prints undefined, Window {...} (or the global object) // obj.c(); // prints 10, Object {...} // var obj = { // count : 10, // doSomethingLater : function(){ // setTimeout(function(i){ // the function executes on the window scope // this.count++; // return ()=>console.log(i.count); // }(this), 300); // } // } // obj.doSomethingLater() // String.prototype.jdEmpcode = function(){ // if(this.length >= 6){ // return this; // }else{ // return this.padStart(6, '0'); // '0009' // } // } // let empcode = new String("6492"); // console.log(empcode.jdEmpcode())
Editor Settings
Theme
Key bindings
Full width
Lines