草庐IT

is-there-an-environment-variable-

全部标签

javascript - 将函数调用保存到变量时为 "object is not a function"

我试图通过将函数缓存到变量来使我的代码更小。例如:functiontest(){vara=Array.prototype.slice,b=a.call(arguments);//DosomethingsetTimeout(function(){varc=a.call(arguments);//Dosomethingelse},200);}所以我可以不调用Array.prototype.slice.call(arguments),而是调用a.call(arguments);。我试图通过缓存Array.prototype.slice.call使它更小,但那不起作用。functiontest

javascript - Socket.configure Undefined is not a function 错误

注意:我使用的是MacOS10.10Yosemite重要说明:其他问题和答案均对我无效。我正在学习教程,这样我就可以玩多人游戏了。有一个文件,我必须下载,其中有一个game.js文件,我需要将此代码添加到:注意:我在正确的目录中正确下载了socket.io。varutil=require("util"),io=require("socket.io").listen(80);varsocket,players;functioninit(){players=[];socket=io.listen(8000);socket.configure(function(){socket.set("t

Javascript : How to create global functions & variables

我想创建一个可以在元素上使用的新函数,如下所示:document.getElementById("element").myNewFunction();我不是在说这个:document.getElementById("element").myNewFunction=function(){doSomething...}因为这仅适用于该元素,但我应该如何创建全局函数,以便我可以在所有元素(如JavaScript内置的元素)上使用? 最佳答案 使用Element的原型(prototype)来扩展其功能:Element.prototype.m

javascript - 为什么这不是 google.maps.Map 的 map 实例?无效值错误 : setMap: not an instance of Map;

我收到错误Assertionfailed:InvalidValueError:setMap:notaninstanceofMap;而不是谷歌地图网页上StreetViewPanorama的实例。然后我读了thisquestionStackOverflow上的其他地方告诉我我需要一个google.maps.MAP对象的实例。我认为通过调用该对象来初始化我将调用该对象的map。以前,我收到错误iisnotdefined所以我将createMarker函数移动到$.getJSON函数中,它有本地范围。我需要在其他地方调用google.mapsMap吗?我做错了什么?HTML:HelloWor

javascript - 扩展EventEmitter时如何解析 'this is not defined'?

这个问题在这里已经有了答案:"UncaughtReferenceError:thisisnotdefined"inclassconstructor(1个回答)关闭6年前。以下代码失败:varEventEmitter=require('events');classFooextendsEventEmitter{constructor(){this.name='foo';}print(){this.name='hello';console.log('world');}}varf=newFoo();console.log(f.print());并打印错误this.name='foo';^Ref

javascript - 为什么 push 显示 argument of type 'any[]' is not assignable to parameter of type 'never' 错误?

在这段代码中我得到了休闲错误:Argumentoftype'any[]'isnotassignabletoparameteroftype'never'varmarkers:[];this.Getlapoints(this.map.getCenter(),500000).then(data=>{for(varkeyindata){Leaflet.marker(data[key].location,//{icon:greenIcon}).addTo(this.map).bindPopup(data[key].caption);//markers.push(data[key].locatio

Javascript arguments.sort() 抛出错误 sort is not a function

只是想知道为什么我在使用以下简单的JavaScript函数时会出错functionhighest(){returnarguments.sort(function(a,b){returnb-a;});}highest(1,1,2,3);错误消息:TypeError:arguments.sort不是函数。我很困惑,因为它是一个数组(我认为)。请帮助并解释原因。非常感谢 最佳答案 因为arguments没有sort方法。请注意arguments不是Array对象,它是一个类似数组的Argumentsobject.但是,您可以使用Array

javascript - "require is not defined"使用 webpack 2

我在使用webpack捆绑我的应用程序时遇到问题,尽管我已经尝试了所有建议,但我在网站上看到了类似的问题,但我无法弄清楚哪里出了问题。一切都很好。但是,当我打开浏览器时显示此错误:未捕获的ReferenceError:未定义要求webpack-dist.conf.jsconstwebpack=require('webpack');constconf=require('./gulp.conf');constpath=require('path');constHtmlWebpackPlugin=require('html-webpack-plugin');constFailPlugin=r

javascript - Photoshop 脚本 : Move an image to position x, y

我有一个事件的ArtLayer被变量NewLayer引用,我想移动到Canvas中的绝对位置x,y。我已经用谷歌搜索了几个小时,但没有任何结果。有人可以举个例子吗?//谢谢。 最佳答案 经过更多API阅读和搜索后,我得出的结论是只能使用增量移动来移动图层。我编写了这个小函数来将图层定位在绝对位置。希望这对下一个有同样问题的读者有所帮助...//******************************************//MOVELAYERTO//Author:MaxKielland////MoveslayerfLayert

javascript - 获取 `TypeError: jest.fn is not a function`

我正在尝试使用Jest创建以下单元测试。jest.dontMock("pointsAwardingActions.js");describe("pointsawardingactions",()=>{describe("awardpoints",()=>{it("shoulddispatchbeginajaxaction",()=>{varpointsAwardingActions=require("pointsAwardingActions.js");constmockedDispatch=jest.fn();});});});但在运行npmtest后我收到以下错误。TypeErro