« first day (2012 days earlier)      last day (3158 days later) » 

Well, the guy still insists on using document.write, so my downvote stays
74
Q: Stack Snippets console output

gion_13I recently answered a Stack Overflow question and inserted a stack snippet for a quick demo of my solution. However, it was a simple JavaScript-only related problem and I didn't use any other panels (HTML/CSS) and the result was the classic console.log(result). I was wondering if there should be ...

sad this got shuffled off as "just use this extension"
@Hisham put semicolon after as--
What do you mean by haywire?
@rlemon if you see that a demo is outputting to the console, you should open up the console. I know you agree with me, but I'm just saying that people need to use their brains
:/ document.write. I wouldn't have an issue if this method got removed from the js engines
13:01
@ndugger yes and I'm just pointing out that it is a shame that the system doesn't do this for us in the interface they provide
not all dev tools are equal, and this would bridge that
@KarelG document.write can be useful with iframes, or something... I have no idea these days
@ndugger No, not really...
alright, then yes, it should go die, lol
in iframes?
It's been a long time since I've used iframes
13:03
There are legitimate reasons to use doc.write. For example, it's easier to use than var s = new Script; s.async = false; s.src = ...
@rlemon All dev tools are equal. Some are equal more.
Can you install Polymer JS with NPM?
@RomanPerekhrest and hypothetical user will come here to learn some stuff, see document.write and think "ohh this is correct". proliferating bad code should be avoided. I don't see why this is even a discussion. — rlemon 9 secs ago
Better to err in the way that breaks your code than to err by not following best practices
user5992646
:)
13:04
@JanDvorak a. Wrap it in a function, done. b. If by any chance the page had finished rendering before you used document.write you're screwed.
True and true :)
@rlemon this is why I don't answer on main anymore. After I've set people straight in comments, I no longer have faith in people lol
@Neil that does not help, as--; go haywire
Rur. to go wrong; to malfunction; to break down. i think
the OP who we're hijacking his answer is fine (he did add a disclaimer)
it is the high rep users going "ay m8, doc.write is fine, sit down" who are wrong
@Hisham I am familiar with the definition. I meant, what doesn't it do right? Does the div get removed?
13:06
@rlemon @ndugger You should have done that from the beginning...
Oops, when I posted the comments deleted. Should I delete my comment?
@MadaraUchiha I can't. I don't have high enough rep to make edits happen right away. Mine have to get approved, and OP's usually reject my changes if they disagree with good practices.
I've had it happen many times before
I'm helpless in that fight
I'd rather tell RomanPerekhrest why advocating for bad code is a terrible idea, and why "let them fail, they'll learn" is pretty much the worst approach ever
@rlemon it isn't enough to be a right answer. It must also be best practice imho
doc.write is fail-fast, though. That is nice of it.
13:07
@Neil this isn't a case of that. it is a case of "here, you can use this shovel to hammer in a screw"
if you're blatantly using the wrong tools, that is a problem.
@ndugger So sit down and get to 2k already
remember, newbs come here to learn (idk why :P)
@MadaraUchiha make me
doc.write is good enough for debugging purposes as long as you know to not use it for anything else - which you'll learn with the first integration test.
@JanDvorak doc.write has exactly zero advantages over the alternatives.
user5992646
13:09
After knowing some PHP, JS is not so hard anymore. So, happy. :)
It's not better than doc.body.textContent = when you need to output to the screen, and it's not better than console.log() when you just need to log something out.
ohh well
@rlemon My second day of Javascript forgetting. :) (source)
@MadaraUchiha true, but there are some cases where the disadvantages don't apply either
@rlemon After forgetting some PHP, JS is not so hard anymore. So, happy. :) (source)
13:10
@JanDvorak There are also plenty of cases where the disadvantages of using the Array constructor don't apply either
only times I've seen doc.write used effectively was in hacks to include libs (which are hacks)
Doesn't mean it isn't a bug factory that's best avoided until you're absolutely sure you know what you are doing.
@Neil but if the user created 3 fields and deleted 2nd one and added one again . it duplicates the 3rd field ..i want to disable the remove button if the user added one more after it.
true. I've used var buffer = Array(w*h) myself, too.
If I switch from Array to a typed array, should I expect a visible speed increase?
@JanDvorak On the client side?
Don't count on it.
13:12
why is React so unnecessarily complicated? :|
@corvid what is so complicated about it?
It's being heavily accessed in a tight loop
@Loktar react-router takes some time
or at least, did for me
as in, nine reads, some arithmetics and a write.
@Loktar pretty much, I just want to display a list of data on the DOM, but the setup to do that is kind of ridiculous
13:14
@Hisham you're not duplicating anything in your code from what I recall.
@rlemon that's like calling JQuery complex because of some plugin though
@corvid there is a chunk of boiler plate for sure
@Loktar I suppose, but react-router is needed to do pretty much anything outside of hello world no? (all the tuts I followed used it defacto)
div.html('<div class="form-group" style="margin-top:10px;"><label>'+b+as+'</label><input class="form-control" placeholder='+b+as+' type="text" name= '+nm+as+++' ><input class=" remove btn btn-primary" style="margin-top: 5px;display: inline;" type="button" value="Remove Topic"/></div>');

$("#TextBoxContainer").append(div);
@rlemon Depends on how you use React
But generally, yeah.
fair enough
13:15
@rlemon if you're making a single page app. React-router is pretty popular but you don't have to use it
@Hisham this creates a whole new element
But then you have to understand the boilerplate, and I am trying to use it with electron which makes it more complex
@corvid yea I gave up on it with electron
user5992646
JS inbuilt functions are case-sensitive? confirm for me. :)
@corvid the only boilerplate/sestup I'm speaking of really is webpack :P
13:16
@rlemon What did you use instead?
throw it in nw.js
plain js, ejs for templating
yes it has variable (as) as value , lable , name
which incriments on each click
@TodoPertin yes, case sensitive
user5992646
@Neil thank you, friend. :)
13:17
@Hisham yes, and the adding works
@corvid because my 'back end' (electron, so no back end really, just the proc) knows of my DOM already, I didn't really find it too much to bind everything by hand
@TodoPertin but don't have functions with the same name regardless
user5992646
@Neil ok I will try not to. but I create typos a lot. thank you again. :)
I see, I would be connecting to a database via mongodb, so the only complication really is updating the dom and binding data
it works only if the user chooses to go systematically , if he chooses to add three elements and remove the 2nd one of them the variable as goes one short .. which makes it 3 when i add one more it remains 3 instead of 4
13:19
What the fuck linkedin lol
@Hisham why do you need to use a variable?
Nice eh?
Wouldn't it be better to simply append to the end?
i need the field name to be different for the backend use.
!!s/na/ga/
13:23
@Hisham you can name it field [] with the square brackets
@jAndy i need the field game to be different for the backend use. (source)
You can have multiple fields with same name
!!s/sa|na/ga/g
@jAndy You can have multiple fields with game game (source)
which game?
13:24
@jAndy you lose
!!s/which/THE/
@jAndy THE game? (source)
how to access it on backend . i take it as $this->input->post('topic'); on backend
Did... jAndy just troll himself?
@Hisham it should be an array on the backend
13:26
looks like CI
I do not miss php
yup
@rlemon miss php? If that were a pageant, miss php would be a talkative dumb blonde
> 🍁jAndy Canada, eh?
win
user5992646
lol
O_O
13:32
@Hisham try simplifying your code to work without having to keep track of the state of things (the state is the DOM)
@Neil i want the label , place holder to be different for each field.. is it possible to do that without the variable
php isn't that bad
2
I've been working with it for a couple weeks now, and the new version is easy to understand and write good code with
is codeigniter dead?
@Hisham when you want to add a new element, just determine the number of inputs then
Don't bother keeping track
Jordan, you traitor! Only php haters allowed in here.
13:35
Sterling, someone is teasing you by starring your post
Plus, after coming from CF, php must seem amazing...
CF ?
coldfusion ?
never tried that language
PHP was the first language I learned :P
13:35
Jordan is our in-house CF pro
@SterlingArcher Stockholm syndrome
he he , web dev w/o php. thats gonna happen.
@SterlingArcher not so bad if you know that Java is the first language for many developers because it's used as step up into coding at colleges
I even had a course where you had to use Java for computer vision because the docent says so
@rlemon: Stop being mean. *Sadface*
You meanie
?
stop taking it personal?
13:37
I believe that Haskell should be taught in math courses. And then teach imperative programming.
I don't agree with you on procedure about something almost pointless :P
I'm not
i protested when he announced that at the first lecture. Java is far from the right language for computer vision
I just think a answer on there is more valuable than comments comparing my answer to w3schools.
* shakes fist *
13:38
^ joins in with @KarelG
To be fair w3schools is pretty useful in some cases
how long will it take for node js to take over all the php code on the internet . maybe not
@Firedrake969 as a scare example?
@Cerbrus that wasn't a dig on you, that was a plain comparison that the mentality "ohh ignore that bit of code, it wasn't meant to be showing you anything important" is flawed. SO MUCH bad practise has been learned from w3schools for exactly that mentality
13:38
@Hisham require("gun"). Bam.
@JanDvorak quick reference if I forget something
Come on, that comment isn't constructive, @rlemon
it is perfectly constructive!
lol
> PHP is used by 82.3% of all the websites whose server-side programming language we know
@Firedrake969 MDN does it better
13:39
You know it ain't ;-)
it is exactly the point I'm making
It's generally the first or second result, and it's pretty simple
code and live example
That speaks against Google, not for W3[^c].*
What I meant is that it's easy to access
so is MDN
13:40
So is pornhub
It's fairly simple as well
code example, and live example
and it works for me so yeah
@Firedrake969 The problem is the quality
Except the code is better not read
And a noob doesn't know good code from bad code yet
dammit, stop posting above me
To be fair there are a few issues, but that page was for appendChild
user5503464
13:42
-1
Q: How can I check given date is between two dates in mongodb?

komal{ "_id": { "$oid": "asdf976" }, "Categories": [{ "mainmodels": [{ "submodels": [{ "price": "2000", "submodelname": "lumia021", }, { "price": "2000", "submodelname": "lumia341", } ], "Status": "Active", ...

@SterlingArcher historical reasons + lots of support in that language
user5503464
help me out
not even a please?
where are your manners?
the problem with 'demo code' is that if you don't explicitly call out what is known to be bad practise, the entire snippet is going to be viewed as proper from your audience (the people using you to learn. The people who already know it is bad probably don't look at those answers as much)
@Firedrake969 that code is pretty short and yet there's one thing I would never do.
13:43
Being?
@komal Didn't you already ask this question here?
the 2nd line ...
@komal the answer you were given on your question is correct. Research it, don't just immediately say "i dont get it"
> To be fair there are a few issues, but that page was for appendChild
@Cerbrus you basckstabber. Saying document.write is fine... You're sick.
13:43
@komal that answer is google-able. Please use it. I can formulate an answer without googling. Try to understand it
apart from that I'd never use textNodes explicitly if possible (set textContent), they're inconsistent between li and LI
again, agreed
Capital letters in createElement offend me
@ndugger Context
@Firedrake969 that's a poor argument
13:44
When I said
> To be fair w3schools is pretty useful in some cases
I meant for myself
also, they fail the "don't comment the obvious" rule
@SterlingArcher What is getElementsByTagName then doing to you?
@Firedrake969 and yet you were wrong
It is fine, in Stack Snippets, as an alternative to `console.log, which isn't supported.
@Cerbrus the context is that newbies will come in and see document.write, and then they'll start using it all over their code, because they don't know how bad it is. That's all the context you need.
13:45
@jAndy not the function name, you nerd! :P
It's never fine
As a param
@KarelG When I'm using it as a reference, it works because it shows me the correct usage of appendChild - and that's what my first statement about w3schools was about
We can't protect newbies against everything
@SterlingArcher ohh ;)
13:46
Oh and... w3schools are still using var. let is the new fad :-D
so many fads in JS :P
@Cerbrus if you use document.write, you will get pregnant and die
3
In which order?
@Cerbrus No, but if not using document.write protects them from something so stupid, shouldn;t we? Expecially when there are acceptable alternatives?
13:46
@SterlingArcher You're never ever used it?
he is still alive
@ndugger Acceptable alternatives like?
That was just a joke, but I've actually never used it
so no.. obviously not
!!s/document.write/javascript/
13:47
@JanDvorak @Cerbrus No, but if not using javascript protects them from something so stupid, shouldn;t we? Expecially when there are acceptable alternatives? (source)
I was taught not to use it (shockingly) when I learned
@Cerbrus like document.body.textContent and console.log, which does output to the console.
Just open the devtools
@Cerbrus Once in the past 4-5 years
It's not magic
nor is it advanced
@ndugger Textcontent is hardly better.
13:47
Yes it is
And that one time was to deliberately write code with bad practices and errors in it.
but that aside, you still have the console
the console exists for a reason
@MadaraUchiha RIP *sadface*
using document.write is worse than using alerts for debugging
disputable
13:48
0
A: Stack Snippets and document.write

rlemon even if it's clearly only for the purpose of demoing it on Stack Overflow? My problem with willy-nilly tossing document.write into answers without disclaimer is that many new JavaScript developers will be reading the answer and taking the entire thing in, not instinctively knowing that docum...

@ndugger I wouldn't go so far.
ugh, I hate writing meta posts
@rlemon Thank you
it isn't that I don't care. but I feel like they should be better formatted than comments
comments are easier
wrtng iz hrd
3
A: Moving int values from an array to another one

Rayon Dabre Use Array#filter, The filter() method creates a new array with all elements that pass the test implemented by the provided function. var firstArray = [1, 2, "Blue", "Yellow", 5, "Orange"]; var op = firstArray.filter(Number); console.log(op); <script src="http://gh-canon.github.io/stac...

13:50
You might say you're a dreamer, but you're not the only one. — ndugger 12 secs ago
@MadaraUchiha @rlemon ^
@SterlingArcher I know of that
Still a terribly ugly solution
somewhat related: meta.stackoverflow.com/questions/273049/… would be nice to just be able to have a 'show console' button (opening my own console is too hard) — rlemon 38 mins ago
YOU'RE A TERRIBLY UGLY SOLUTION /me youtube.com/watch?v=fvM_nlTqdQ0
> I've met some folks who say that I'm a dreamer,
> And I've no doubt there's truth in what they say,
> But sure a body's bound to be a dreamer,
> When all the things he loves are far away.
13:53
http://codepen.io/TechTreeDev/pen/VadjBR
Does the location and the weather match with yours?
@rlemon LOLWUTGAWG ... did someone made a meta of that ?
* picks my axe *
@TechTreeDev I'm not in the Netherlands, so no
@deceze are you against new coders learning/teaching them things or something? If they ask, point them in the right direction. It's super easy — Sterling Archer 18 secs ago
I said "relevant" not "solved" -_-
@ndugger AH, let me guess Elsloo?
@TechTreeDev Yes
13:54
@ndugger Damn. Thank you
> Why didn't you tell my son the wire is under high voltage?
> He didn't ask.
@JanDvorak You own a sun?
uh... no? (thanks)
I didn't know document.write was such a hot topic
@SterlingArcher it's the eval of the dom api
@SterlingArcher "hot spot" is what compiler developers call a piece of code that takes up a lot of time.
Is that a fact?
I didn't know there was a term for that
Oh okay, I found out you can use express, I gave up on trying to get a meh-tier front end framework to work.
@TechTreeDev var loc = getLocation; <-- if you're calling a function (which it is).... use () ...
@JanDvorak We just call it "bottleneck"
13:57
@SterlingArcher a "hot pocket" is a tasty snack
that works, too
@Neil well... not quite
A hot spot in computer science is most usually defined as a region of a computer program where a high proportion of executed instructions occur or where most time is spent during the program's execution (not necessarily the same thing since some instructions are faster than others). If a program is stopped randomly, the program counter (the pointer to the next instruction to be executed) is frequently found to contain the address of an instruction within a certain range, possibly indicating code that is in need of optimization or even indicating the existence of a 'tight' CPU loop. This simple...
!!urban hot pocket
13:58
!!undo
@CapricaSix Uhhhhhh....
Gets me everytime
Good ol' urban dictionary. Destroying childhoods one at a time
!!urban childhood
@JanDvorak childhood Where the opposite sex had cooties, pokemon was life,a kiss made the pain go away,the ice cream man was God,green veggies were the devil,finger panting and nap time went hand-n-hand.
13:59
@Neil haha yep ;-)
@KarelG I tried this but it doesnt display anything afterwards

« first day (2012 days earlier)      last day (3158 days later) »