JSFiddle - React, Tailwind, and code Playground

by Samar Pattanayak

JavaScript

function demo(msg){
	this.msg= msg;
}
demo.prototype.add1= function(namearr){
	'use strict'
	//alert(this.msg + name);
  //var that=this
  //return namearr.map(function(arg){
  	//return  this.msg + arg;
  //},this)
  return namearr.map(arg => {return this.msg + arg});//it works
  //otherwise you can bind "this" as a second parameter of map function to //bind msg variable from lexical environment or use arrow function :)
}
var d1= new demo("Hello ");
console.log(d1.add1(["samar","baisali","shiva","raghu "]));
//console.log(typeof () => {});//not ok
console.log(typeof (() => {}));//its ok
//you can use type of in expression body without ();
//ES6 forbids a line break between the parameter definition and the arrow of an arrow function:
//const f = x =>  (bar: 123 )//error
(()=> console.log("selef invoking function in ES 6"))();

const as = new Set([1, 2, 3]);
const bs = new Set([3, 2, 4]);
const intersection = [...as].filter(bs.has, bs);
console.log(as.entries())
console.log(intersection)
//const intersection = [...as].filter(a => bs.has(a));

console.log("*****************************************************")
const first = 'Jane';
const last = 'Doe';

const obj = { first, last };
// Same as:
//const obj = { first: first, last: last };
console.log(obj.first)
//***
const arr=[4,3];
const propKey = 'foo';
const obj2 = {
    [propKey]: true,
    ['b'+'ar']: 123,
    [arr[1]]: false
};
console.log(Object.keys(obj2))
console.log(obj2["3"])
//console.log(obj2.3)//error but why
console.log(obj2["foo"])
console.log(obj2.foo)

const objAss = { foo: 123 };
let obbbbbb=Object.assign(objAss, { bar: true });
Object.defineProperty(objAss,"bar2",{
	value:false,
  enumerable:true
})
console.log(JSON.stringify(objAss));
console.log(JSON.stringify(obbbbbb));
for(let key in objAss){
	console.log(objAss[key])
}

function clone(orig) {
    return Object.assign({},...