草庐IT

is_undefined

全部标签

javascript - Push is not a function JavaScript 错误

在下面的代码中,出现“推送不是函数”错误。任何人都可以让我知道我在这里做错了什么吗?我正在尝试用Javascript创建二维数组。varmyArray=newArray(4);myArray=["0","0","0","0"];for(vari=0;iFirebug指向我:myArray[i].push("ID");对于这一行,我收到“TypeError:myArray[i].pushisnotafunction”最终的数组应该是这样的:[ID,"SomeValue1"],[ID,"SomeValue2"],[ID,"SomeValue3"]而且我不能硬编码,我需要根据数据库中的数据动

javascript - 了解 Javascript : how it works, 中的 “undefined” 如何安全地检查它以及是否可以重新分配

我一直在阅读JavaScript中的undefined,现在我不确定我的理解是否正确。关于如何检查undefined有很多讨论,但不知何故我找不到任何提及对我来说似乎是理解undefined实际工作方式的基础的东西(undefined是宿主对象的属性)。这就是这个问题的原因,我需要确认我理解的是正确的,如果我错了,我希望得到澄清。好的,首先,undefined是宿主对象(浏览器中的window)的属性,因此使用它是完全合法的:window.undefined此属性的值是"undefined"类型。这是与Object、String、Number和Null一起的JavaScript类型之一

javascript - 代码给出错误 "ReferenceError: CryptoJS is not defined",而我已经包含了必需的 .js 引用,原因是什么?

这是我的代码,我包含了以下.js文件,在页面加载时出现错误“ReferenceError:CryptoJS未定义”为什么在已添加js引用时出现该错误。我正在使用Office365制作Sharepoint-2013应用。'usestrict';varcontext=SP.ClientContext.get_current();varuser=context.get_web().get_currentUser();(function(){//ThiscoderunswhentheDOMisreadyandcreatesacontextobjectwhichis//neededtouseth

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 - 鉴于 V8/spidermonkey/chakra 的内部工作原理,在 JavaScript 中显式初始化 undefined object 成员是否是一种优化?

在JavaScript中,一个通常被吹捧的良好性能原则是避免改变对象的形状。这让我想知道,这是不是classFoo{constructor(){this.bar=undefined;}baz(x){this.bar=x;}}一个有值(value)的最佳实践,将提供比这更好的性能classFoo{constructor(){}baz(x){this.bar=x;}}这是真的还是假的?为什么?在一个JS引擎中是否比其他引擎更真实或更不真实? 最佳答案 这里是V8开发人员。是的,总的来说,第一个版本是一个有值(value)的最佳实践。这样

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

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

javascript - 谷歌地图未捕获类型错误 : Cannot read property 'LatLng' of undefined

我不断收到此错误“未捕获的类型错误:无法读取未定义的属性‘LatLng’”尝试创建map时在头部:................functioninit(){varlatlng=newgoogle.maps.LatLng(-43.552965,172.47315);varmyOptions={zoom:10,center:latlng,mapTypeId:google.maps.MapTypeId.ROADMAP};map=newgoogle.maps.Map(document.getElementById("map"),myOptions);}................

javascript - Fabric.js 子类化 fabric.Group - 错误 : "Cannot read property ' async' of undefined"when load from JSON

有以下问题:尝试继承fabric.Group:varCustomGroup=fabric.util.createClass(fabric.Group,{type:'customGroup',initialize:function(objects,options){options||(options={});this.callSuper('initialize',objects,options);this.set('customAttribute',options.customAttribute||'undefinedCustomAttribute');},toObject:functi

javascript - "Unable to get property ' getData ' of undefined or null reference"在 IE 但不是 Chrome

感谢另一位成员的帮助,我成功地实现了一个JS方法,该方法能够粘贴excel数据并将其拆分为HTML文本框表格形式(seethread)。我现在面临的问题是这只在Chrome中有效,而IE10和IE11都标记了以下错误:“无法获取未定义或空引用的属性‘getData’。”此错误在函数的第2行(如下)中抛出:function(event){varinput_id=$(this).attr("id");varvalue=event.originalEvent.clipboardData.getData('text/plain');//ERRORinIE/*...*/event.prevent

javascript - 未捕获的类型错误 : Cannot read property 'toUpperCase' of undefined react state item

我是React和Javascript的新手,我正在尝试呈现以下React组件:'usestrict';varReact=require('react');importToReadListfrom'./toreadlist.js';varToRead=React.createClass({getInitialState:function(){return{bookTitles:[]};},handleSubmit:function(e){e.preventDefault();this.state.bookTitles.push(React.findDOMNode(this.refs.bo