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({},...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.