其他

還沒歸進上面主題的題。

11 / 11 題 · 依票數排序

5.5k

How do I create a GUID / UUID?

How do I create GUIDs (globally-unique identifiers) in JavaScript? The GUID / UUID should be at least 32 characters and should stay in the ASCII range to avoid trouble when passin…

2008javascriptguiduuid·3 重點答案·3.3M 次瀏覽
2.7k

Can (a== 1 && a ==2 && a==3) ever evaluate to true?

Moderator note: Please resist the urge to edit the code or remove this notice. The pattern of whitespace may be part of the question and therefore should not be tampered with unne…

2018javascriptecmascript-6·3 重點答案·436k 次瀏覽
2.5k

JavaScript equivalent to printf/String.Format

I'm looking for a good JavaScript equivalent of the C/PHP printf() or for C#/Java programmers, String.Format() ( IFormatProvider for .NET). My basic requirement is a thousand sepa…

2009javascriptprintfstring.format·3 重點答案·2.6M 次瀏覽
1.9k

How do I remove a key from a JavaScript object?

Let's say we have an object with this format: var thisIsObject= { 'Cow' : 'Moo', 'Cat' : 'Meow', 'Dog' : 'Bark' }; I wanted to do a function that removes by key: removeFromObjectB…

2010javascript·3 重點答案·2.1M 次瀏覽
1.8k

How to measure time taken by a function to execute

I need to get execution time in milliseconds. Note : I originally asked this question back in 2008. The accepted answer then was to use new Date().getTime() However, we can all ag…

2008javascriptprofiling·3 重點答案·1.2M 次瀏覽
1.7k

JavaScript set object key by variable

I am building some objects in JavaScript and pushing those objects into an array, I am storing the key I want to use in a variable then creating my objects like so: var key = "hap…

2012javascript·3 重點答案·1.5M 次瀏覽
1.7k

How to convert a string to number in TypeScript?

Given a string representation of a number, how can I convert it to number type in TypeScript? var numberString: string = "1234"; var numberValue: number = /* what should I do with…

2013javascripttypescript·3 重點答案·2.8M 次瀏覽