草庐IT

Sum_Function

全部标签

Javascript:typeof 说 "function"但它不能作为函数调用

这次我真的对Javascript很困惑:varx=Array.prototype.concat.call;typeofx;//functionx();//UncaughtTypeError:xisnotafunction这到底是怎么回事?如果有帮助,我还注意到:x([1,2],[3,4])也不行toString也认为是一个函数:Object.prototype.toString.call(x);//"[objectFunction]"Array.prototype.concat.apply也会发生这种情况。当它被强制作为一个表达式时它也不起作用:(0,Array.prototype.c

javascript - 未捕获的类型错误 : lang is not a function

这个问题在这里已经有了答案:JSfunctionnamed`animate`doesn'tworkinChrome,butworksinIE(3个答案)关闭6年前。在我的HTML中,我在script标签中定义了lang函数并添加了“TestFire!”单击时必须调用lang的按钮:TestingFunctionsfunctionlang(){alert("Hello,World!It'sJavaScriptthistime");}但是,如果我点击按钮,我会得到这个错误:UncaughtTypeError:langisnotafunction但是,如果我将函数名称从lang更改为任何其他

javascript - 类型错误 : scrollIntoView is not a function

我是react-testing-library/jest的新手,正在尝试编写测试以查看路由导航(使用react-router-dom)是否正确执行。到目前为止,我一直在关注README还有这个tutorial关于如何使用。我的一个组件在本地函数中使用了scrollIntoView,这导致测试失败。TypeError:this.messagesEnd.scrollIntoViewisnotafunction45|46|scrollToBottom=()=>{>47|this.messagesEnd.scrollIntoView({behavior:"smooth"});|^48|}49|

javascript - TypeError [ERR_INVALID_ARG_TYPE] : The "original" argument must be of type Function. 接收类型未定义

在下面的代码中,我得到了这个错误:TypeError[ERR_INVALID_ARG_TYPE]:The"original"argumentmustbeoftypeFunction.Receivedtypeundefinedconstsqlite3=require('sqlite3').verbose();constutil=require('util');asyncfunctiongetDB(){returnnewPromise(function(resolve,reject){letdb=newsqlite3.Database('./project.db',(err)=>{if(e

javascript - 在 nodejs 上访问 function.caller

我有一项任务依赖于function.caller来完整性检查调用者是否获得授权。根据这个url,所有主流浏览器都支持caller...并且我的所有单元测试都通过了:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/caller但是,nodejs拒绝所有访问function.caller的尝试(将其报告为null)。我愿意接受让这个在nodejs上工作的建议...我不希望这个框架只在浏览器上工作。谢谢! 最佳答案

javascript - 无效值错误 : initAutocomplete is not a function Google Places and Autocomplete API

希望您能提供帮助,因为我遇到了困难,我对使用Google的PlacesAPI也很陌生。我现在不打算发布任何代码,因为当我将要描述的2部分独立运行时,我的代码工作正常。除了使用Google提供的Javascript示例的自动完成API之外,我还使用Google的Places。最初我的文档底部有以下脚本:我文档顶部的这个脚本:这让我想到,“您已在此页面上多次包含GoogleMapsAPI。这可能会导致意外错误。”所以在研究了这个之后,我像这样将两者合并在一起:但是,既然我已经这样做了,我会收到以下错误:InvalidValueError:initAutocompleteisnotafunc

javascript - '类型错误 : undefined is not a function' when jumping 'tween modules

我在Node中不断遇到这个问题,每当我相互调用函数时,我的应用程序就会崩溃。我已经做了这个最小的工作示例(按照它的方式工作给了我错误):启动模块varmodule2=require('./module2');vardata='data';module2.doStuff(data);模块2varmodule3=require('./module3');functiondoStuff(data){//Stuffhappensto'data'module3.takeStuff(data);}functiondoSomethingElse(data){console.log(data);}mo

javascript - JSHINT:如何禁用匿名 'function' 后缺少空格的警告

我在jshint中收到了警告'[L76:C24]Missingspaceafter'function''我遵循NicholasZakkasMaintainablejavascript风格,匿名函数后没有空格。如何在jshint中删除此警告?.jshintrc{"node":true,"browser":true,"es5":true,"esnext":true,"bitwise":true,"camelcase":true,"curly":true,"eqeqeq":true,"immed":true,"indent":4,"latedef":true,"newcap":true,"n

javascript - 类型错误 : module is not a function AngularJS & Jasmine

在我的示例应用程序中,我像这样测试运行器收藏夹Controller:varmodule=angular.module('AngularSampleApp',[]);varFavoritesController=module.controller('FavoritesController',functionfavoritesController($scope){$scope.phones=[{'name':'NexusS','snippet':'FastjustgotfasterwithNexusS.'},{'name':'MotorolaXOOM™withWi-Fi','snippet

javascript - D3 : use nest function to turn flat data with parent key into a hierarchy

我确信有一种非常简单优雅的方法可以做到这一点,但我不太明白。我有一些看起来像这样的输入数据:[{id:1,name:"Peter"},{id:2,name:"Paul",manager:1},{id:3,name:"Mary",manager:1},{id:4,name:"John",manager:2},{id:5,name:"Jane",manager:2}]如果可能,我想使用d3.js嵌套运算符来获取要在层次结构布局中使用的结构。像这样:[{name:"Peter",children:[{name:"Paul",children:[{name:"John"},{name:"Jan