草庐IT

object_name

全部标签

javascript - Chrome 控制台中 '[Object]' 和 '[object Object]' 之间的区别?

我有一些类似下面的代码。MyRequests.cors_request("POST",APP_CONFIG.APP_URL+"/users/selectAllUsers",null,functionok(users){$scope.usersNotFiltered=users;console.log('users--->',users);console.log('$scope.userPerSystem--->',$scope.userPerSystem);//deletetheitemsthatisalreadyexistsintheuserPerSystemfunctionfilt

javascript - innerHTML 仅插入 [object HTMLDivElement]

我想在另一个html元素中插入一个htmlsnippet我试过了htmlinsertthishtmlelementintothisjsvarbox1=document.querySelectorAll(".box1")[0];varbox2=document.querySelectorAll(".box2")[0];console.log(box1);box2.innerHTML=box1;但它不起作用,它只插入[objectHTMLDivElement],如果我查看控制台,它会输出正确的html,我做错了什么?是的,我不想使用$库;)http://codepen.io/destroy

javascript - Angular 2 RC 4 "(SystemJS) Can' t 解析 [object Location] : "in IE 11 的所有参数

我的Web应用程序在Chrome、Firefox和Edge中运行良好,但在IE11中当然不行。可能也不是旧版本的IE。它是一个使用AngularCli生成应用程序的最小应用程序。完整错误:EXCEPTION:Can'tresolveallparametersfor[objectLocation]:(?).EXCEPTION:Can'tresolveallparametersfor[objectLocation]:(?).UnhandledPromiserejection:(SystemJS)Can'tresolveallparametersfor[objectLocation]:(?)

JavaScript 对象文字 : Property names as strings vs. "raw"

有没有区别:varx={hello:'world'};和varx={'hello':'world'};?也就是说,在什么情况下,将属性名称作为字符串给出与将其作为“原始”名称给出会产生不同的结果?例如,我知道varx={};x['@£$%']='bling!';是有效的(因为任何字符串都可以是属性),但是x.@£$%='bling!'不会工作。语言关键字或保留关键字也不会作为属性名称(因此varx={for:'good',class:'y'};将不起作用。还有什么吗?例如,如果varhello='goodbye';是在上面的例子中定义的吗?或者其他的,比如functionhello()

javascript - 我可以使用 constructor.name 来检测 JavaScript 中的类型吗

我可以使用“constructor”属性来检测JavaScript中的类型吗?或者有什么我应该知道的。例如:vara={};a.构造函数名称;//输出“对象”或varb=1;b.构造函数名称;//输出“数字”或vard=newDate();d.构造函数名称;//输出“日期”而不是对象或varf=newFunction();f.构造函数名称;//输出“函数”而不是对象只有在参数上使用它时arguments.constructor.name;//像第一个例子一样输出对象我经常看到开发人员使用:Object.prototype.toString.call([])或Object.prototy

javascript - 为什么 ES5 Object 方法没有添加到 Object.prototype 中?

ES5添加了一个number的methods到Object,这似乎打破了JavaScript的语义一致性。例如,在此扩展之前,JavaScriptAPI始终围绕操作对象本身;vararrayLength=[].length;varfirstPosInString="foo".indexOf("o");...新的Object方法是这样的;varobj={};Object.defineProperty(obj,{value:'a',writable:false});...当以下内容更加符合时:varobj={};obj.defineProperty({value:'a',writable:

javascript - 传单未捕获错误 : Invalid LatLng object: (NaN, NaN)

我正在尝试使用传单动态加载map标记,但出现此错误:UncaughtError:InvalidLatLngobject:(NaN,NaN)我正在使用这个javascript加载我的标记:varlat;varlng;for(i=0;i我正在阅读的json是这样的:[{"brewery":"21stAmendmentBrewery","lat":"37.7824175","lng":"-122.3925921","breweryID":"EdRcIs"},{"brewery":"AbitaBrewingCompany","lat":"30.482408","lng":"-90.056605

javascript - 诗乃JS : Is there a way to stub a method on object argument's key value in sinon js

我想在以下响应中模拟对obj.key3值的不同响应。就像ifobj.key3=true然后返回与obj.key3=false不同的响应functionmethod(obj){returnanotherMethod({key1:'val1',key2:obj.key3});} 最佳答案 您可以使用.withArgs()和对象匹配器根据调用它的参数使stub返回(或执行)某些操作。例如:varsinon=require('sinon');//Thisisjustanexample,youcanobviouslystubexistingm

javascript - 在angular2中使用窗口对象但vscode "Cannot find name '窗口'“

我用VisualStudio代码编写了一个angular2应用程序。最近,我将VisualStudioCode更新到了1.10.2。但它已将window突出显示为有错误。当我检查它时,我发现它说:[ts]Cannotfindname'window'.我的代码如下:saveCustomIndex(customIndex:any,indexName:string){window.localStorage.setItem(indexName,JSON.stringify(customIndex));}截图我该如何处理?谢谢! 最佳答案 在

javascript - 为什么 Object.assign 不复制 URL 对象的属性?

在装有Chrome63的macOS10.13.1上。我将Object.assign与newURL()一起使用作为源对象,但它总是给出一个空对象?这似乎是一种奇怪的行为。这是我的代码:leturl=newURL('http://www.yahoo.com');console.log(url);letdata=Object.assign({},url);console.log(data);为什么data是一个空对象,而url有如下完整的URL对象:{href:"http://www.yahoo.com/",origin:"http://www.yahoo.com",protocol:"ht