草庐IT

undefine

全部标签

javascript - 类型错误 : 'undefined' is not an object

我有一个目前相当不正常的Javascript程序,它一直给我带来问题。但是,它引发了一个我不明白的错误:TypeError:'undefined'isnotanobject(evaluating'sub.from.length')正如您可能猜到的那样,我正在尝试做的是检查lengthfrom中的某个“sub”数组字典。这是sourcecodefortheentirefunction,这是我认为导致错误的循环代码:console.log(afcHelper_ffuSubmissions.length);//justfordebugging,returnsthecorrectnumberf

javascript - 为什么 JSLint 推荐 x === "undefined"而不是 typeof x == "undefined"?

我对JSLint感到困惑。我的代码最初检查div:jqmData("me")是否像这样未定义:if(typeofel.jqmData("me")=="undefined"?el.not(':jqmData(panel="main")').length>0:el.not(':jqmData(me="first")').length>0){}JSLint提示我应该用===替换typeof的检查,所以我这样做了:if(el.jqmData("me")==="undefined"?el.not(':jqmData(panel="main")').length>0:el.not(':jqmDat

javascript - NgRX 实体 : ids are undefined in the State

我一直在一个虚拟的“Todo”项目中尝试@ngrx/entity,它有一个AppModule、一个reducer和一个组件。但是,我在尝试时遇到问题。我的操作非常简单,只是一些CRUD操作:import{Action}from'@ngrx/store';import{Todo}from'../../models/todo';exportconstCREATE='[Todo]Create'exportconstUPDATE='[Todo]Update'exportconstDELETE='[Todo]Delete'exportclassCreateimplementsAction{rea

javascript - "window.angular is undefined."使用 Protractor 进行自动化测试时?

我在使用Protractor提供的示例conf.js时似乎出错了。我正在使用grunt-protractor-runner运行测试,但即使使用提供的示例配置也会出错。我的Gruntfile.js看起来像这样:/*globalmodule:false*/module.exports=function(grunt){//Projectconfiguration.grunt.initConfig({protractor:{options:{configFile:"smoketest.conf.js",//DefaultconfigfilekeepAlive:false,//Iffalse,t

javascript - 将值与 'undefined' 进行比较的最佳方法是什么?

有什么区别vara;(a==undefined)(a===undefined)((typeofa)=="undefined")((typeofa)==="undefined")我们应该使用哪一个? 最佳答案 具有讽刺意味的是,undefined可以在JavaScript中重新定义,并不是任何头脑正常的人都会这样做,例如:undefined="LOL!";此时所有针对undefined的相等性检查都将产生意想不到的结果!至于==和===(相等运算符)之间的区别,==将尝试将值从一种类型强制转换为另一种类型,用英语表示意味着即使类型不同

javascript - 将 undefined variable 传递给函数时出错?

我正在尝试创建一个可重用函数来检查变量是否未定义。奇怪的是,当我将变量传递给函数以执行代码时它不起作用,但如果我在函数外部使用相同的逻辑,它就起作用了。有什么方法可以让这个函数isDefined起作用吗?//THISWORKSANDRETURNFALSEalert(typeofsdfsdfsdfsdf!=='undefined');//THISGIVESANERROR,WHY?//UncaughtReferenceError:sdfsdisnotdefinedfunctionisDefined(value){alert(typeofvalue!=='undefined'&&value!

javascript - 未捕获的类型错误 : Cannot read property 'local' of undefined in chrome extension

我写了一个Chrome扩展。我不能使用localStorage.setItem和localStorage.getItem用于存储和检索,因为后台和浏览器操作在不同的环境中运行[asseenhere].所以我决定使用Chrome存储API:varstorage=chrome.storage.local;varmyTestVar='somevar';varobj={};obj[myTestVar]=$("#somevar").val();storage.set(obj);产生了以下错误:UncaughtTypeError:Cannotreadproperty'local'ofundefin

javascript - AngularJS-Bootstrap TypeAhead : TypeError: Cannot read property 'length' of undefined 错误

我在尝试从AngularUI-Bootstrap实现AngularJSTypeahead时遇到以下错误:(我只是调用一个以JSON格式返回结果的servlet)TypeError:Cannotreadproperty'length'ofundefinedathttp://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.11.0.js:3553:24atwrappedCallback(http://ajax.googleapis.com/ajax/libs/angularjs/1.2.10/angular.js:10930:81)at

javascript - 为什么我们需要将 window 和 undefined 传递给这个 jquery 插件?

这个问题在这里已经有了答案:Whatisthepurposeofpassing-inundefined?(3个答案)关闭8年前。我正在查看jqueryresize插件并且无法理解有关其工作原理的某些事情:通常我们只将Jquery对象传入jquery插件,像这样:(function($){....plugincode....})(jQuery);在“调整大小”插件中有窗口和undefinedobject被传入:(function($,window,undefined){....plugincode....})(jQuery,this);恕我直言-窗口无论如何都是一个全局对象-为什么我们需

JavaScript undefined 替换为 null

在JavaScript中,undefined可以重新赋值,因此通常建议创建一个自执行函数来确保undefined实际上是未定义的。作为替代方案,null和undefined肯定是==但是否有任何其他值大致等同于null/undefined?长篇小说基本上你可以安全地替换这个:(function(undefined){window.f=function(obj){if(obj===undefined||obj===null){alert('valueisundefinedornull');}}})();与:window.f=function(obj){if(obj==null){aler