码迷,mamicode.com
首页 > 编程语言 > 详细

javascript函数

时间:2017-06-19 23:31:41      阅读:404      评论:0      收藏:0      [点我收藏+]

标签:声明   pre   asc   js函数   typeerror   script   16px   erro   type   

js函数的分类

 

函数声明

function add(a,b){
   return a+b
}

 

 

函数表达式

<!--一般函数表达式-->
var add = function(){
   
}


<!--立即声明函数表达式-->
(function(){

})()


return  function(){

}

 


 

函数声明被前者

var count  = add(1,2);
console.info(count)   //out:3

function add(a,b){
  return a+b;
}

 

var count = add(1,2);
console.info(count)    //Uncaught TypeError: add1 is not a function

var add  = function(a,b){
  return a+b;
}

 

javascript函数

标签:声明   pre   asc   js函数   typeerror   script   16px   erro   type   

原文地址:http://www.cnblogs.com/dsitn/p/7050955.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!