草庐IT

math-functions

全部标签

c# - 161803398 是一个 'Special' 的数字吗? Math.Random() 内部

我怀疑答案是“因为数学”,但我希望有人能在基本层面提供更多见解...我今天在BCL源代码中翻来覆去,看看我以前使用的一些类实际上是如何实现的。我以前从未想过如何生成(伪)随机数,所以我决定看看它是如何完成的。完整来源:http://referencesource.microsoft.com/#mscorlib/system/random.cs#29privateconstintMSEED=161803398;每次为Random()类播种时都会使用此MSEED值。无论如何,我看到了这个“神奇的数字”——161803398——我完全不明白为什么选择这个数字。它不是素数或2的幂。它不是看起来

jQuery 未捕获类型错误 : Property '$' of object [object Window] is not a function

全部,我下载了一个预捆绑的JS/CSS表单应用程序,我正尝试在Wordpress中使用它。我有以下代码:$(document).ready(function(){/*----------------------------------------------------------------------*//*Parsethedatafromandata-attributeofDOMElements/*----------------------------------------------------------------------*/$.parseData=function

jquery - 类型错误 : 'undefined' is not a function (evaluating '$(document)' )

我正在使用WordPress网站。我将此脚本包含在header中。当脚本加载时,我得到这个错误:TypeError:'undefined'isnotafunction(evaluating'$(document)')我不知道是什么原因造成的,甚至不知道它意味着什么。在Firebug中,我得到这个:$isnotafunction 最佳答案 WordPress在noConflict中使用jQuery默认模式。您需要使用jQuery作为变量名来引用它,而不是$,例如使用jQuery(document);代替$(document);您可以轻

jquery - 如何添加显示:inline-block in a jQuery show() function?

我有这样的代码:functionswitch_tabs(obj){$('.tab-content').hide();$('.tabsa').removeClass("selected");varid=obj.attr("rel");$('#'+id).show();obj.addClass("selected");}show函数添加了display:block。但我想添加display:inline-block而不是block。 最佳答案 尝试使用CSS来隐藏和显示内容,而不是show。functionswitch_tabs(obj

javascript - 打开新的基础元素时出现 "Uncaught TypeError: a.indexOf is not a function"错误

我通过bash创建了一个新的Foundation5元素,foundationnewmy-project。当我在Chrome中打开index.html文件时,控制台中显示了一个UncaughtTypeError:a.indexOfisnotafunction错误,源自jquery.min.js:4.我按照基金会网站上的步骤创建了元素,但我似乎无法摆脱这个错误。Foundation和jQuery看起来它们包含在index.html文件中并正确链接,链接的app.js文件包含$(document).foundation();有谁知道是什么导致了这个错误?什么是解决方案?

javascript - Function.prototype.call.bind 是如何工作的?

我在思考这个函数时遇到了一些麻烦:vartoStr=Function.prototype.call.bind(Object.prototype.toString);toStr([])//[objectArray]​​​​​​​​​​​​​​​​​​​​​​​​​​​如第2行所示,此函数如何接受参数? 最佳答案 嗯,Function.prototype.call引用“call”函数,该函数用于调用具有选定的this值的函数;随后的.bind引用Function原型(prototype)上的“bind”函数(记住:“call”也是一个函

javascript - 禁用 JSHint 警告 : Expected an assignment or function call and instead saw an expression

这个问题在这里已经有了答案:Expectedanassignmentorfunctioncallandinsteadsawanexpression(4个答案)Whydoesjshintnotrecognizeanassignmentasanexpression?(8个答案)关闭7年前。我有以下行:imageUrl&&(data.imageUrl=imageUrl);对于这一行,JSHint提示:Expectedanassignmentorfunctioncallandinsteadsawanexpression.我理解警告,但我想禁用它。我找不到怎么做的方法。有什么想法吗?

javascript - 使用 $(function 等启动 javascript 代码

我正在研究来自http://todomvc.com/的Backbone和todo示例应用程序我注意到有3种启动文件中代码的方法:$(function(){//codehere});$(function($){//codehere});(function(){//codehere}());我不明白其中的区别以及何时应该使用其中一个。我还看到一些人用它来开始他们的代码:$(document).ready(function(){//codehere});据我所见,这是完整的写法吧?以更一般的方式,我是否应该始终将我的javascript代码包含在每个文件中的类似内容中?感谢您的建议。

javascript - .substring 错误 : "is not a function"

我不明白为什么我使用substring方法声明变量时会收到错误消息。我想在比较中使用URL的第一部分。网站:http://www.elizabet.nl/wordpress这是出错的部分:varcurrentLocation=document.location,muzLoc=currentLocation.substring(0,45),prodLoc=currentLocation.substring(0,48),techLoc=currentLocation.substring(0,47);错误:“currentLocation.substring不是函数”但这部分代码没问题:va

javascript - 从 Cloud Functions for Firebase 中的数据库触发器获取用户 ID?

在下面的示例中,是否有办法获取写入/messages/{pushId}/original的用户的uid?exports.makeUppercase=functions.database.ref('/messages/{pushId}/original').onWrite(event=>{//GrabthecurrentvalueofwhatwaswrittentotheRealtimeDatabase.constoriginal=event.data.val();console.log('Uppercasing',event.params.pushId,original);constu