Personally, I’m not against the use of FF, but in order to have a consistent meaning, a word must always have the same abbreviation, don’t you agree? That’s my thoughts on it, anyway–kind of like the same reason why we have standardized HTML.
Let’s not get off topic, though. I don’t think Ultimater would appreciate that.
Visit Slightly Remarkable to see my portfolio, resumé, and consulting rates.
That discussion seems awfully familiar, much like the one between NN and NS.
I prefer NS over NN and I prefer FF over Fx.
Anyways, BigMoosie, How is the variable t1 involved here?
Originally Posted by BigMoosie
Code:
Function.prototype.time = function() {
var t1 = new Date();
this.apply(null,arguments);
var t2 = new Date();
var t3 = new Date();
return 2*t2 - t3 - t2;
};
Would you mind rewriting the function so I can provide a clean link to it from my index in the first post?
For me personally, this is the most useful prototype function in this thread.
Often I will want to know the position of... say the third occurance of a string within another. This is similar to indexOf() but instead of just getting the first occurance you can specifiy a second argument which will be the nth occurance.
Specifying a negative value for n will count from the back rather than the front.
Specifying no value for n will presume the value 1 for n.
Specifying a string or decimal or zero for n will return -1.
If the string is not found at the nth occurance will also return -1.
Yep its fixed. I also made a fix to String.dex(), didnt realise till i saw yours that indexOf() took 2 arguments. My version drains less resources from the computer as it only calls indexOf() as many times as it has to.
For Those who dont know what factorial is it is the number of sequences that can exist with a set of items, derived by multiplying the number of items by the next lowest number until 1 is reached. For example, three items have six sequences (3x2x1=6): 123, 132, 231, 213, 312 and 321. Also note that zero factorial (in Maths noted by 0!) is equal to 1.
This code is remarkably less laggy than traditional scripts for two reasons. If the input is greater than 170 then JavaScript will naturally overflow the value to infinity, instead of trying that this script will just presume that from the start. Also, once a value has been recognised, any factorial value below that is indexed in an array so subsequent calls will drain much less resources. I challenge anybody to beat this script in efficiency.
I guess the easiest way to beat that script for efficiency would be to simply store the factorials for all numbers up to 170 in a hard-coded array from the very beginning and return the appropriate NaN or Infinity otherwise. You'd never spend any time computing values, or checking for their existence in the array, since you already have them all.
Of course, that is a pretty lame approach...
Kids, kids... you tried your best, and you failed miserably; the lesson is: never try.
String.prototype.replaceAll=function() {return this.split(arguments[0]).join(arguments[1])}
test="It Did Not Work"
test=test.replaceAll(" Not","")
alert(test)
Bookmarks