Arrow Function
ES5 feature
by Yogesh Rathod
HTML
<div id='div1'>
</div>
JavaScript
var obj = {
collection : ['yogesh','sunita','Rushi'],
domain : 'rathod.com',
method : function method(){
var mapEmail = function (item){
return item + '@' + this.domain;
}.bind(this)
return this.collection.map(mapEmail);
}
}
//alert(obj.method());
var obj1 = {
collection : ['yogesh','sunita','Rushi'],
domain : 'rathod.com',
method : function method(){
return this.collection.map(item =>{
return `${ item }@${ this.domain }`;
});
}
}
//alert(obj1.method());
//Template String
var mydata = {
greeting : 'hello..'
}
var template = `<div>${ mydata.greeting }<div>`;
//alert(template)
//What are Rest Arguments
//If the last named argument is prefixed with (...), the argument collects itself and all consecutive arguments.
printObject({'name':'Yogesh','name':'Sunita','name':'Rushi'})
function printObject(){
var args = [].slice.call(arguments,0);
args.forEach(function(arg){
alert(JSON.stringify(arg))
})
}