草庐IT

STRING_VALUE

全部标签

javascript - Jquery 速度,使用 .html(string) 真的很慢,我怎样才能加快速度?

我有一个函数平均需要250毫秒才能完成。我想在更短的时间内完成此操作,functionupdateDisplay(){varstart=newDate().getTime();var$this=$(this);vardata=$this.data('ansi');varhtml='';for(vari=0;i';}varcreate=newDate().getTime();console.log('Buildhtml:'+(create-start));$this.html(html);varend=newDate().getTime();console.log('Updatehtml

Javascript : Strange behaviour `empty string` AND `false` returns empty string

今天我遇到了Javascript中的奇怪行为。下面是代码return""&&false返回“”。为什么会这样? 最佳答案 因为TheproductionLogicalANDExpression:LogicalANDExpression&&BitwiseORExpressionisevaluatedasfollows:LetlrefbetheresultofevaluatingLogicalANDExpression.LetlvalbeGetValue(lref).IfToBoolean(lval)isfalse,returnlval

javascript - ES6中扩展String时的错误

'usestrict';classReverseStringextendsString{reversed(){letres='';for(leti=this.length-1;i>=0;--i){res+=this[i];}returnres;}}letrs=newReverseString("wangyang");console.log(rs.reversed());当我运行这段代码时,我遇到了一个错误:C:\Users\elqstux\Desktop>nodewy.jsC:\Users\elqstux\Desktop\wy.js:14console.log(rs.reversed(

javascript - 如何更改h :outputText value by JavaScript?

我已经用2个inputText测试过,它运行良好例如vartdate=document.getElementById('txtDate');//h:inputTextvartdt=document.getElementById('txtDateTime');//h:inputTexttdate.onchange=function(){tdt.value=tdate.value;};如何更改“tdt”-h:outputText的值?vartdate=document.getElementById('txtDate');//h:inputTextvartdt=document.getEle

c# - SCRIPT5009 : 'JSON' is undefined in IE 10 The value of the property '$' is null or undefined, 不是函数对象

HelloWorld$(document).ready(function(){});$(document).ready(function(){$("#width").val($(window).width());$("#height").val($(window).height());});上面是我的aspx代码和jquery脚本,它给出了窗口的高度和宽度。当我从visualstudiohttp://localhost/Mypage.aspx运行web应用程序时,这段代码在所有浏览器上都完美无缺但是当我在iis上托管它并使用我的机器名称http://MyMachine/Mypage.a

javascript - 是否有任何标准的 JavaScript API 或库将字符串作为 String 对象返回?

直到最近,我才意识到JavaScript中有两种类型的字符串(以及bool值和数字):诸如"blah"之类的原语,以及诸如new之类的对象String("blah").它们的区别在于很容易“陷入困境”的方式,其中最大的一个似乎是不同的typeof值(“string”vs“object"),但还存在许多其他差异,一些documentedatMDN.创建String对象没有意义,因为原始字符串也能正常工作,而且JSHinteventreatsthisasanerror.所以我真的很想假装String实例根本不存在,并且在我的代码中只支持原始字符串。这让我想知道:我可以通过调用一些返回字符串

javascript - 优化 : Get specific Value(and not more) from IndexedDB

我正在做的是在客户端上保存和检索大量图像。(现在indexedDB对于这个简单的工作来说似乎有点过分了,但是因为它是唯一没有限制的跨浏览器解决方案(比如localStorage),所以我不得不使用它......而且它有效)这是我的数据库的样子:(更具体地说,我的数据库的唯一对象库)#|key(timeID)|value0|812378123|{data:¨....¨,tnData:¨...¨,timeID:812378123}1|912378123|{data:¨....¨,tnData:¨...¨,timeID:912378123}2....KeyValue是一个唯一的TimeID,

javascript - 使用 String.localeCompare 对混合项目进行排序时如何更改排序顺序?

假设我们有一组具有混合name值(nums、cyrillic、english)的对象:(如果代码不适合你,把undefined改成'ru',它也会改变排序结构)letascending=truevaritems=[{name:'c',value:''},{name:'b',value:''},{name:'a',value:''},{name:'д',value:''},{name:'в',value:''},{name:'41',value:''},{name:'а',value:''},{name:'б',value:''},{name:'0',value:''},{name:'3

javascript - 当存在全局标志时,为什么 String.match() 不产生预期结果?

这个问题在这里已经有了答案:JavaScriptregularexpressionsandsub-matches(2个答案)关闭9年前。我正在尝试这场比赛'/links/51f5382e7b7993e335000015'.match(/^\/links\/([0-9a-f]{24})$/g)得到:['/links/51f5382e7b7993e335000015']当我期待的时候:['/links/51f5382e7b7993e335000015','51f5382e7b7993e335000015']在删除全局标志之前,我没有运气,我认为这不会影响我的结果!移除全局标志后,'/lin

javascript - String.charCodeAt 未定义?

尝试在Safari3中调用String.charCodeAt('9')时,javascript调试面板出现此错误。TypeError:Resultofexpression'String.charCodeAt'[undefined]isnotafunction.当我尝试执行stringInstance.charCodeAt('9')时,我得到了NaN。难道我做错了什么?我只想获取某些字符的字符代码以匹配按键。String.charCodeAt('9')在Firefox上返回57(如预期)。 最佳答案 我认为正确的做法是:"9".cha