首页 > 其他 > 详细

es6特性(function函数)

时间:2017-02-12 15:52:12      阅读:179      评论:0      收藏:0      [点我收藏+]

定义函数

我们先来看一个基本的新特性,在javascript中,定义函数需要关键字function,但是在es6中,还有更先进的写法,我们来看:

es6写法:

var human = {
    breathe(name) {   //不需要function也能定义breathe函数。
        console.log(name + ‘ is breathing...‘);
    }
};
human.breathe(‘jarson‘);   //输出 ‘jarson is breathing...’

转成js代码:

var human = {
    breathe: function(name) {
        console.log(name + ‘is breathing...‘);
    }
};
human.breathe(‘jarson‘);

es6特性(function函数)

原文:http://www.cnblogs.com/weirenxing/p/6390992.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!