« first day (985 days earlier)      last day (3958 days later) » 

8:00 PM
@BenjaminGruenbaum so store it somewhere and pass that into each bind
 
@Shmiddty how?
 
@RobW waaaaay too broad
 
The question has been updated
Looks better now
 
I'm voting to reopen
 
It boils down to "How to get a list of all variable assignments and declarations from an AST tree"
 
8:01 PM
people, how can i achieve this, start at 9 chars into a string and get everything before until the next space?
 
Don't vote yet
 
if you understand that?
 
A moderator should delete all answers and comments to give the question a fresh start
 
well his original question and his update are not at all the same :P
 
user1125394
!!> print(5)
 
8:02 PM
his update makes senseish.
his original question was just sloppy
 
!!live
 
function Func(fn){
	fn.partial = function(){
		for (var i = 0, l = arguments.length;i<l;i++)
			fn = fn.bind(fn, arguments[i]);
		return fn;
	}
	return fn;
}
 
I think it might be easier if he just flags it for deletion and creates a new question
 
@Shmiddty That would still lock fn wouldnt it?
 
@rlemon agreeeeeeeeeed
 
8:04 PM
It's a fair question
There are plenty of ways to declare variables :)
 
the new question is fair, the old question was a clusterfluck.
"what are all possible ways to declare variables" is a blanket question
I thought SO didn't like blanket questions
 
SO likes questions that'd take a simple Google to answer, so long as you're the first.
 
user1125394
too-opened?
 
now his new question sheds some light on why he wanted to do this, and has value.
just my thoughts.
 
@BenjaminGruenbaum I'm not sure what you mean.
 
8:05 PM
@riemon Let's hope that it's his original question. What he has written down is based on what I wrote in the comments.
 
@SomeKittens SO likes questions that SO has already answered :P
 
@Shmiddty Bind is permanent, I wouldn't be able to change its value of 'this' once I use it.
 
@RobW ohh wow, I Didn't read all the comments, only about half the answers.
I did read his Q however.
 
@BenjaminGruenbaum each bind overwrites the thisParam iirc
 
8:07 PM
@Shmiddty Nope
!!> (function(x){return this+x;}).bind(5).bind(7)(5)
 
@BenjaminGruenbaum nice try
 
user1125394
I'd like to use this at least once in my js code, just for its beauty
 
@BenjaminGruenbaum 10
 
8:08 PM
@JanDvorak Thanks caprica
 
anyone
7 mins ago, by Connor
people, how can i achieve this, start at 9 chars into a string and get everything before until the next space?
 
@riemon What do you mean by " I feel someone should note assignment in a j = k = N type pattern is not horrible, only declaration."?
 
user1125394
!!> this
 
@Connor "before until"?
 
@Connor x.slice(8).match(/\S+/)[0]
 
8:11 PM
@RobW if k and N are not declared as local variables, they will be global
 
@Shmiddty say i have this string 'hello how are you' i want to start at 9 in wich would be 'hello how| are you' and i wan't to get everything before it untill the space
lol wow
 
"hello how are you".slice(8).match(/\S+/)[0] => 'w'
 
so you would want "how" ?
 
@JanDvorak that is close, but it gets after
i think
hold on
 
`indexOf(char,int)
x.slice(x.indexOf(' '),8)
 
8:14 PM
@JanDvorak yours is close but i need 'ho'
cool
 
uh? so, the last word of the 9-character prefix of x?
 
@JanDvorak that works thanks
@JanDvorak i think x.slice(x.indexOf(' '),8) this works
im double checking
 
@Connor please check I'm not one-off somewhere
 
"hello how are you" <- do you want "hello ho" or ??
@JanDvorak how did you interpret his requirements :P
 
var x = "hello how are you"; x.slice(x.indexOf(' '),9); // " how"
this works great thank you
 
8:17 PM
@Connor this slices off the first space
 
you probably want x.slice(x.slice(0,9).lastIndexOf(' '), 9);
 
do you want the last word of the 9-character prefix of x?
or, the word that appears at position 9?
 
how about some example inputs and expected outputs? :P
 
15 mins ago, by rlemon
I think it might be easier if he just flags it for deletion and creates a new question
 
8:18 PM
@BenjaminGruenbaum I'm waiting for The Cleaner ♦ to delete all those comments and answers before voting to re-open stackoverflow.com/q/17351705
 
@rlemon It's got 3 out of 5 alreadyt
 
Hey, anyone recall how to bind one function to another so that when one function is called the other gets called too?
 
a word that ends on character 9!
 
(assuming his new Q is his real Q) the massive amounts of bad answers and comment hell could be cleaned up - or he could just post a clean Q and we could del that ??
 
ok i have this string `var x = 'hello how are you';` and i have a caret here like this `var x = 'hello how| are you`; // <= then i want 'how'
or if i have this `var x = 'hello how are| you`; // <= then i want 'are'
 
8:19 PM
@Braden you could replace the original funcion with a new one
 
@Jan
That's not an option :(
 
personally I think a clean Q would be to his benefit. but I have no stake in this :P so idc.
 
@Connor what if it's 'hello ho|w are you?
 
then i want 'ho'
 
x.slice(x.slice(0,index).lastIndexOf(' '), index);
 
8:20 PM
@Connor what if it's 'hello |how are you'?
 
@Braden you have to modify the original function or wrap them
I don't see any other way
 
@Connor You sound like a rapper.
 
and you can always override the function
 
@SomeKittens Lmao
 
@Connor Yeah, that's what I was thinking....wondering if there is any way to do it simply with a magic jquery function or something
 
8:21 PM
"hello how are you?".slice(0,8).split(' ').pop();
 
@Braden oldFunc = obj.func; obj.func = function(){...; oldFunc.apply(this, arguments)}
 
@nderscore unfortunately the | is a caret not actuall char
 
var _oldFunc = someFunc;
someFunc = function(){
    _oldFunc();
    someOtherFunc();
}
 
@Braden
function foo() { /* code you are told not to change, but this needs to call bar() */ }
var fakeFoo = foo;
foo = function() {
    fakeFoo.apply(fakeFoo, arguments);
    bar();
};
 
"hello how are you?".slice(0,8).split(' ').pop();
 
8:23 PM
@nderscore not bad
 
obj.func = (function(func){
  return function(){
    ...
    return func.apply(this, arguments)
  }
})(obj.func)
 
Eek that question got opened again
 
0
A: All possible ways to declare Javascript variables

Benjamin GruenbaumI think it's pretty much impossible Here is why I think it's pretty much impossible without executing it: Let us go through the unexplored parts, from easy to hard. Easy to catch: Function scope is missed here: (function(x){ //x is now an object with an a property equal to 3 // for t...

 
And another answer kicked in already :p
 
the inner function needs to return the original return value of func :P
 
8:24 PM
Oh from yours hehe
 
@BenjaminGruenbaum you were just sitting and waiting
I knew it.
 
@RobW fixed
 
@rlemon I was writing, not sitting :)
 
try{ throw 5}catch(x){
    x // x is now declared in the scope of the try block and is equal to 5;
}
makes me cringe
so hacky
 
It's hacky, but it's there.
> (people reading: I beg you to please not use these last two for actual scoping in code :))
 
8:25 PM
!!s/too/two/
 
Also, with the new question most of these answers are obsolete. @Mods? Course of action? flag one? flag many? downvote and let authors deal with? — rlemon 1 min ago
 
Yeah, already edited :(
 
missing double quote in new Function("window.x = 5)();// or global in node
 
I'd much rather use an IIFE if I really needed block scoping
but honestly, there's not much need for block scoping.
in day-to-day stuff
 
I send the data to my webserver then have a php js parser to parse it and return some JSON data to the client which contains the symbol table.
@BenjaminGruenbaum clearly the only way
ohh, and I use phpQuery as well
because..
 
8:29 PM
I have this regex:
new RegExp(
'^(([0-9 \\' + this.options.thousandsSeparator + ']{0,6})' +
'(?:\\' + this.options.decimalSeparator + '\\d{0,3})?)?$'
)

{0,6} should really only apply the the numerical portion of the first line, but I don't want to restrict where they place the thousands separator (since we just sanitize this)
 
@RobW None of these (JSHint, UglifyJS, Closure Compiler) will find dynamic definitions, if I base64 decrypt a string into eval none of them will catch it (nor would it be reasonable to expect them to do so). IDEs and linters are very good and I enjoy them, but some things are just not reasonable for them to find. If you see how I concluded my answer I think it sums it up nicely: "I have seen no IDE that has been able to deal with anything but these. Since they're the most common by far, I think it's perfectly reasonable to count those." — Benjamin Gruenbaum 18 secs ago
 
how can I make that happen?
 
@RobW Generally, the second I can invoke the compiler all goes to hell :)
@Shmiddty Of course, it's also a lot faster except for in one browser (guess which!)
@JanDvorak ty
 
@BenjaminGruenbaum But once someone uses eval, he has already given away the opportunity to get something useful from it
Instead of finding a 100% satisfying solution, 90% would already be better
As a starting point, compare what you can get to the case that the symbol contains all syllables of the text.
 
@RobW brackets cause the same amount of grief for properties as eval does for variables
 
8:33 PM
@RobW I agree! I covered the cases he can do that are not in his list nicely I think (let me know if you find more). The dynamic cases are pretty much impossible (well, as possible as the halting problem :)).
 
document.forms.codeInputForm.elements.codeInputTextarea.onblur = function() {
  var code = this.value;
  while(true) {
    eval(code);
  }
};
^ this is safe right?
 
That's too much information, any algorithm can improve on it.
 
@BenjaminGruenbaum Opera?
 
user1596138
!!is she dead?
 
@Shmiddty What browser makes you really angry in general?
 
8:34 PM
@rlemon umm...
 
@BenjaminGruenbaum Safari?
 
Safari / Opera enrage me more than IE
at least IE users know their browser sucks
 
haha
 
@Shmiddty IE :P
 
8:34 PM
I'm trollin
 
user1596138
I'd much rather use Safari than IE.
 
@rlemon et's just say he user could enter "1" and freeze his browser
 
user1596138
Safari isn't that bad. It has issues with canvas but other than that I don't mind it at all. Chrome is my favorite by far though.
 
Let's downvote the obsolete answers
 
@JanDvorak ok. so I should change it to eval(code-1) ???
 
user1596138
8:35 PM
I'm biased against Mozilla for now because of pdf.js and how it's literally ruined pdf viewing on FF.
 
can i haaz kode plz?! tanks.
@Jhawinsss FF annoys me
I used to be a FF guy, but then Chome Dev Tools.... damn I love them
 
user1596138
I don't mind FF. But really have you seen what pdf.js does to things?
 
brb smoke
 
more than firebug
 
@RobW I have to admit, downvoting competing answers makes me feel uneasy although I understand the point.
 
8:36 PM
@rlemon then you're sure to have an infinite looopeh
 
@JanDvorak hr,.. so what you are saying is I need to do this:
$(document).ready(function() {
  document.forms.codeInputForm.elements.codeInputTextarea.onblur = function() {
    $code = $(this)[0].value;
    while($(true)) {
      eval(code);
    }
  };
});
 
ok so, slice returns a certain part of the string that you have selected , what method do i use to return the string without a the selected word? i can't find anything in google
 
!!/tell Connor mdn string.slice
fuck
 
ive been there
 
@Connor split or replace?
 
8:38 PM
i am there
 
@rlemon try while(false) instead of while(true). That should be safe.
 
but the user is wanting action? no false. action. hey! i come for code not ridicule! give me code!
 
user1596138
best example I can come up with right now....
 
user1596138
 
user1596138
8:40 PM
 
keeping in mind that there can be many of the same words, that i only want to remove one.

so this `'something else'.slice(10, 14);` returns 'else' i need to get 'something '
 
have you looked into substr and substring?
 
@rlemon var x=1; while(x--){...}
 
user1596138
Just look at those two pngs. That's ridiculous.
 
@rlemon i am there and i think it only returns the word that you want to remove not the string with the word removed
 
user1596138
8:42 PM
Going home. Later
 
@Connor slice doesn't modify the original string either
 
@Connor What do you think of ..... wantedstring = string.replace('the word that needs to be removed', '');
 
it returns a portion of the string without changing the original value
 
i know that's why im asking, what can i do
 
So, would anyone be interested in me downloading Windows 8.1 and telling you how good IE11 is or testing stuff? I have access to msdn subscriber bizspark so I can get that sort of stuff for free
 
8:43 PM
you want to remove a specific word from a string?
 
2 mins ago, by Connor
keeping in mind that there can be many of the same words, that i only want to remove one.

so this `'something else'.slice(10, 14);` returns 'else' i need to get 'something '
 
do you always know the word?
 
@RobW you're going to accumulate extra spaces
 
is there a map object around?
 
@rlemon i have the word in a variable. i don't personally know it :)
@rlemon i didn't get map object around?
 
8:43 PM
@JanDvorak Then turn the needle in a regexp and add \s* around it
 
@RobW then you remove too much whitespace
 
If that is not flexible enough, use a function as the replacement (second argument) instead of ''.
Like
 
@rlemon i want to remove a word at a certain position, and get the modified string back
 
@RobW what about replace(/\s+/," ")?
 
Hey guys, little question. If I want to reach an element in css I can use something li'ke: #right svg { } is something like this possible in jquery ? So something like $("#right svg").click(function(){ ?
 
8:45 PM
var string = "hello monkey balls", findWord = 'monkey';
string = string.split(' ').filter(function(v) { return v !== findWord }).join(' '); string;
"hello balls"
huzzah
 
wantedstring = string.replace(/(\s*)needle(\s*)/, function(full_match, s1, s2) {
    return s1 || s2 ? ' ' : '';
});
// This removes the needle from the string, plus some extra surrounding whitespace if needed
 
@Kasper yep. Jquery selectors are mostly a superset of CSS selectors
 
@JanDvorak ah cool, thanks :)
 
@RobW s/\|\|/&&/
 
@rlemon i know how to do that? the problem is what if this was the case
var string = "hello monkey balls monkey", findWord = 'monkey';
string = string.split(' ').filter(function(v) { return v !== findWord }).join(' '); string;
 
8:46 PM
I dislike regex. so instead I give you es5 answer
string = string.split(' ').filter(function(v) { return v !== findWord }).join(' ');
 
it returns "hello balls"
 
what you only want to strip one?
 
@rlemon much better :-)
 
@JanDvorak || is correct. If a space exists at either side, keep a single space. Otherwise return an empty string.
 
8:47 PM
@BenjaminGruenbaum Should be back up now. Stupid errors not closing the socket...
 
@rlemon i want to remove monkey if its at a certain position so like if i wanted to remove the first monkey it would start at 6
 
!!are you there?
 
@BenjaminGruenbaum Indeed
 
!!what is love?
 
@BenjaminGruenbaum love (uncountable) An intense feeling of affection and care towards another person.
 
8:48 PM
@RobW this will introduce outer whitespace if the last/first word is removed
@BenjaminGruenbaum baby don't hurt me
don't hurt me
no more
 
@BenjaminGruenbaum The system76 one.
 
do you understand rlemon
 
The company I'm working at can help me bring it here.
Since they also do bulk import/export
 
String.prototype.removeAt = function(p, l) {
  return this.substr(0, p) + this.substr(l);
};
huzzah
p is start index, l is the length of the word
 
my god, they've answered
Now I feel bad for whining.
 
8:50 PM
@SimonSarris it was your bitching that made them get off their asses
 
@Darkyen You're welcome. What for?
 
@SimonSarris Ouch.
I experience the same though.
 
New close reasons are turning this site for the better
 
I haven't seen any of my reported bugs getting fixed (except for one, which caused crashes)
 
-7
Q: PHP regular expression for xxx-xxx-xxx that contains only numbers

MBAsfoorI need regular expression for checking phone number format xxx-xxx-xxx I'm not good at regular expressions so can you help me with this?

 
8:53 PM
@IvanChub Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
@rlemon Thanks trying it now
 
@Zirak No you're not, it's an overpriced mediocre laptop. Get the Vostro and shaddap.
 
@BenjaminGruenbaum It's better than all laptops here in the same price range. It's better than the vostro at a lower price.
 
Normally, these would get answered. Now, we're able to say "go do your homework yourself".
 
@JanDvorak Demonstrate the meaning of the problem solved is amazing.
 
8:55 PM
Also, I think we've got an official response on typo questions: flag them.
at least, until the next revamp.
 
@Zirak Vostros are around 950$. The Gazelle is 1250$.
 
not sure if speedy deletion was warranted here, howev... scratch that. Users now can view their own deleted questions.
 
@JanDvorak Yeah
 
@BenjaminGruenbaum Gazelle is $800. Let's say with a 20% tax it's $1000
 
Great... now I've topped my comment vote limit
 
8:59 PM
@Zirak You ain't going to buy that with a non IPS monitor or 4 gigs of ram
@JanDvorak Happens :P
 
with 3 hours to spare
 
@Zirak It's $1168.00 to be reasonable without tax. (8 gigs of ram and SSD)
 

« first day (985 days earlier)      last day (3958 days later) »