大佬教程收集整理的这篇文章主要介绍了angularjs – angular.isUndefined(value)和不是!(value)之间的区别是什么?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
var foo = false; if(!foo) { // will log console.log("foo is defined but false"); } if(angular.isUndefined(foo)){ // will not log as foo is defined console.log("foo is undefined") }
另一个没有定义foo的例子
if(!foo) { // will throw exception "Uncaught ReferenceError: foo is not defined " console.log("foo is defined but false"); } if(angular.isUndefined(foo)){ // will log console.log("foo is undefined") }
如此有效的angular.isUndefined(foo)除了评估之外别无他法
if(typeof foo == "undefined")
为了节省1个字符包裹是的.
while!-operator检查定义的变量是否计算为false
所以
if(!foo)
是一样的
if( foo != truE)
更新:
以上是大佬教程为你收集整理的angularjs – angular.isUndefined(value)和不是!(value)之间的区别是什么?全部内容,希望文章能够帮你解决angularjs – angular.isUndefined(value)和不是!(value)之间的区别是什么?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。