草庐IT

Out-Null

全部标签

javascript - d3.event 在 debounced 函数中为 null

尝试使用mousemove事件处理程序的去抖动版本时,d3.event为null。我想在此去抖动处理程序中使用d3.mouse对象,但d3.event返回null并引发错误。如何在以下代码中访问d3.event://asimpledebouncefunctionfunctiondebounce(func,wait,immediate){vartimeout;returnfunction(){varcontext=this,args=arguments;varlater=function(){timeout=null;if(!immediate){func.apply(context,a

javascript - JS 错误消息 textContent 设置为 null

这个问题在这里已经有了答案:WhydoesjQueryoraDOMmethodsuchasgetElementByIdnotfindtheelement?(6个答案)关闭2年前。我对JS和Web开发领域还很陌生,如果我的问题有点乏味,请提前致歉。我写了这段代码:varbreakfast=newObject();breakfast.food="croissant";breakfast.extra=["mushroom","cheese"];breakfast.eat=function(){returnthis.food+"with"+this.extra[0];}varelBreakfa

javascript - 无法获取属性值 ____ : object is null or undefined

我已经研究过了。Stackoverflow上已经有几篇关于此的帖子,但似乎都没有给我答案。与此处的其他帖子一样,它在Chrome或Firefox中运行良好。但是在IE9、8、7和6中我得到了同样的错误。我已经尝试过强制9进入兼容模式的hack,但它没有解决问题。这是说无法获取属性“styleHelper”的值:对象为空或未定义,具有讽刺意味的是,如果我在IE9中输入控制台window.microstrategy.bone("W2552_Ctl").styleHelper它可以工作并返回我需要的函数(该ID是由WYSIWYG创建的,不要讨厌我)。是的,所有内容都包含在$(document

javascript - null 作为上下文传递给函数调用

请解释这里使用了什么hack(我可以看到null作为上下文传递给返回其上下文属性的函数。所以我不能清楚地理解这里实际发生了什么。functiongetGlobal(){return(function(){returnthis.dust;}).call(null);} 最佳答案 将上下文设置为null将使this指向全局对象。因此,所提供的代码将用作访问全局对象的dust属性。根据ECMA262v5规范,10.4.3进入函数代码ifthisArgisnullorundefined,settheThisBindingtothegloba

javascript - AngularJS 未知类型错误 : Cannot Read Property '1' Of Null

下面是我遇到问题的代码://MainCodesfortheDiaryApp(function(){//Createanewdiaryappvardiary=angular.module('diary',['ngRoute']);//DefineaRouterfortheAppdiary.config(function($routeProvider){$routeProvider.when('/',{templateUrl:'partials/wall.php',controller:'DiaryWallController'}).when('/images',{templateUrl:

javascript - "Unable to get value of the property ' appendChild ': object is null or undefined"同时将脚本附加到 IE

当我尝试将以下脚本附加到IE时,出现此错误:“错误:无法获取属性‘appendChild’的值:对象为空或未定义”它在Chrome中运行良好,但在IE9上测试时会出现这种情况。谁能告诉我错误是什么?//createscriptindocumentvarfbScript=document.createElement("script");fbScript.type="text/javascript";//makescriptsourcethefacebookpluginfbScript.src="http://connect.facebook.net/en_US/all.js#xfbml=

javascript - 无法读取 null 的属性 childNodes

为什么我会收到无法读取null的属性childNodes的错误?此代码是从SAMS24小时自学Javascript一书中获得的。To-DoListvartext="";varpElement=document.getElementById("toDoNotes");for(vari=0;iThingsToDoMowthelawnCleanthewindowsAnsweryouremailMakesureallthesearecompletedby8pmsoyoucanwatchthegameonTV! 最佳答案 您的代码需要在页面完

javascript - null 是一个对象吗?

这个问题在这里已经有了答案:关闭12年前。PossibleDuplicate:NullobjectinjavascriptNull是一个对象吗?所以如果我将x设置为null,为什么我不能获取构造函数值?varx=null;alert(typeofx);alert(x.constructor);

javascript - 如何解决这个 "Uncaught TypeError: Cannot convert undefined or null to object "

我的功能是:functioncollect_que_ids(e){varval=e.val();vardata_lo=e.attr('data-lo');new_hash={};new_hash[val]=data_lo;if(e.is(':checked')){if(checked_box_hash.includes(new_hash)){checked_box_hash;}else{checked_box_hash.push(new_hash);}}else{new_hash_key=Object.keys(new_hash)[0]new_hash_value=new_hash[n

javascript - 如何在 js 中同时检查 null 和 undefined?

是否可以在javascript中同时检查null和undefined?if(_var==null||_var==undefined){} 最佳答案 在JavaScript(ECMAScript5之前)中,undefined不是常量,而是全局变量,因此可以更改其值。因此,使用typeof运算符来检查undefined会更可靠:if(typeof_var==='undefined'){}此外,如果未声明变量_var,您的表达式将返回ReferenceError。但是,您仍然可以使用typeof运算符对其进行测试,如上所示。因此,您可能更