首页 > 编程语言 > 详细

javascript function

时间:2014-11-25 12:41:14      阅读:315      评论:0      收藏:0      [点我收藏+]
function assert(value1, value2) {
  if (value1) {
    console.log(value2);
  }
}

function isNimble() {
  return true;
}
assert(typeof window.isNimble === "function", "is isNimbl() defined");
assert(isNimble.name === "isNimble", "isNimble() has a name");

var canFly = function() {
  return true;
};
assert(typeof window.canFly === "function", "canFly() defined");
assert(canFly.name === "", "canFly() has no name");

window.isDeadly = function() {
  return true;
};
assert(typeof window.isDeadly === "function", "isDeadly() defined");
assert(isDeadly.name === "isDeadly", "isDeadly() has a name");

function outer() {
  assert(typeof inner === "function", "inner() in scope before declaration");
  function inner () {}
  assert(typeof inner === "function", "inner() in scope after declaration");
  assert(window.inner === undefined, "inner() not in global scope");
}

outer();
assert(window.inner === undefined, "inner() stilll not in global scope");


window.wieldsSword = function swingsSword() { return true; };
assert(window.wieldsSword.name === ‘swingsSword‘, "wieldSword‘s real name is swingsSword");
"is isNimbl() defined"
"isNimble() has a name"
"canFly() defined"
"canFly() has no name"
"isDeadly() defined"
"inner() in scope before declaration"
"inner() in scope after declaration"
"inner() not in global scope"
"inner() stilll not in global scope"
"wieldSword‘s real name is swingsSword"

 

javascript function

原文:http://www.cnblogs.com/Iwillknow/p/4030957.html

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