« first day (2062 days earlier)      last day (2904 days later) » 

3:00 PM
550
Q: How does the "this" keyword work?

Maxim GershkovichI have noticed that there doesn't appear to be a clear explanation of what the this keyword is and how it is correctly (and incorrectly) used in JavaScript on the Stack Overflow site. I have witnessed some very strange behaviour with it and have failed to understand why it has occurred. How doe...

read that thoroughly before you use this
 
The price is so wrong @KendallFrey @BenjaminGruenbaum
 
@SterlingArcher It's just an arm workout, bruh
 
@SterlingArcher LOL
I thought she was going to have to pull the wheel
and not be able to get to it
 
@Loktar now that would be ironic
she's been pulling wheels her whole life
 
LOL
 
3:05 PM
OH MY GOD
 
thanks @ssube helpful. Next time could you be a bit calmer and just give me that link first
 
@RowanHarley No, but if you keep vamping (asking for help without trying anything), we're going to kick you.
 
Yeah @ssube calm down
 
Guys why does it seem like people hate asynchronous sometimes? :|
 
:P
@corvid because they like multi-threaded blocking behavior better probs
Oh @Loktar Beartooth's album dropped on friday apparently
 
3:07 PM
@corvid do you mean async/await or async in general?
general async is pretty hard to reason about
 
@SterlingArcher My tits are perfectly calm
 
async/await is anti-sugar, hiding a lot of complexity that actually matters
 
(not actually true, it's freezing in here)
 
@ssube Async in general, including promises or callback-type functions. A lot of frameworks I come across keep trying to make code look much less synchronous
 
3:08 PM
@ton.yeung six
six bandwidth
 
@ton.yeung speed matters too
 
@corvid because it's super hard to read async code.
 
@ssube since when?
 
the control path is not linear at all, it jumps around between functions/modules
 
@KendallFrey since the days of async.js
 
3:10 PM
sometimes it will call a cb, sometimes not, it's just bad
 
I dunno, with plain promises it looks manageable
 
promises make it a lot flatter
 
well-formatted code with promises can be decent, though
 
@ssube who uses callbacks anymore?
 
async/await, though, take it too far and you lose any indication that it was async, which breaks it the other way
 
3:10 PM
your mom uses callbacks.
 
@KendallFrey technically, everybody still uses them
 
promises uses callbacks internally
 
@Luggage his mom doesn't need to callback, you just show up and she lets you in
 
Yeah but as the sole strategy for async, nah
 
the tweet content is useless, but the gif is amazing twitter.com/iamdevloper/status/712574452697989120
 
3:12 PM
!!afk on highway to hell
 
I can't stop laughing
 
@ssube what?
 
@SterlingArcher If I wanted to watch someone taking a shit, it wouldn't be here
 
You respect Chris Farley this instant!
 
3:17 PM
@FlorianMargaine have you seen sadserver?
 
@ssube !!!!!!!!!!!
thabks
 
embrace the futility and despair of the end times deploy mongodb buy oracle vote trump
"Let's deploy Openstack!" from the group with other popular comedy hits such as "MySQL is a database" and: "I know what I'm doing"
 
@ssube That tweet makes me irrationally angry.
 
sadserver and swiftonsecurity are the best
 
The end is nigh. Let's meet it halfway
 
3:20 PM
I've heard Linux On The Desktop is going to be Bernie's VP.
 
@Loktar I tried Ultra Nightmare last night...nope, nope nope nope.
 
@ssube how do you show tweets
I would cry myself to sleep but the Linux ACPI module doesn't support that on my hardware.
Doesn't matter
 
Why doesnt jQuery code work in IE10 but not in Edge? What the difference...
 
@Navitua Welcome to the JavaScript chat! Please review the room 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.
 
Can you convert a later schedule into a crontab?
 
3:30 PM
@Navitua Microsoft Edge is a completely different application to IE
This is a good tweet:
Siri, what am I doing with my life?
 
Shouldn't it be better...
 
@corvid not sure, although that would be cool.
 
@Navitua jquery.com/browser-support Assuming you're up to date, it should work.
 
@Navitua go into the console and see what the error is..
 
My money is you screwed up your code somewhere.
 
3:32 PM
<cough>dick</cough>
 
why test IE10 instead of 11 or 9?
 
or does it work in both 11 and 9?
 
@corvid from the docs, I'm not really seeing any output functions at all.
 
3:33 PM
I have both a registration an a login form on the landing page in my Express app. My route is app.post('/').function() {//creating the user }. Needless to say, it creates a new Null user on each login, since it's a post request from that same page. How do I make Node distinguish between them?
 
app.post('/register')?
 
@ndugger You still maintaining Blackbeard? I'd love to see how it matures.
 
@Kevin B But they're on the same landing page
 
why?
 
3:34 PM
I can't have them on different routes
 
@RowanHarley Are you even old enough to remember the days of IE 7 and below?
 
2 forms post-ing on the same landing page
 
m59
Can this be simplified? (foo 2> /dev/null || true) && bar Entirely swallow the error from foo if there is one and then do bar
 
I never used it! Never will
 
In IE11 is also not working but i used the X-UA-Compatible
 
3:35 PM
@m59 that's pretty simple already
 
!!afk Buying more garlic, the vamps are getting out of control.
 
then you'll have to differentiate them in the code based on what data is passed in. but you're better off having two endpoints, and just have the form's action change based on what action is happening.
 
@Megaplex I bet you're all happy your comment from yesterday turned out to be true.
 
Great idea @KevinB
 
m59
@ssube Sure, I was just wondering if there's a shortcut.
 
3:36 PM
@ssube yeah, I work with ops people :)
 
@m59 I mean, foo 2> /dev/null; bar
 
haha lol
 
old IE jokes
now it isn't slow anymore
it's just weird
 
hello guys who has used AWS S3 before
 
3:40 PM
it's fast and bad
@Lamar yes
 
It's ui doesn't look good
 
have you use the metadata field ? when you are uploading or retrieving from S3 @ssube
 
ui from Edge?
 
@Lamar no, actually. We've been talking about it a bunch recently, but aren't doing anything with it yet.
-1
Q: Is there any difference between JAVA and JAVA script logic

Akhil VijayI am using NetBeans8 IDE . function animate() { xnow = parseInt(item.style.left); item.style.left = (xnow+1)+'px'; ynow = parseInt(item.style.top); item.style.top = (ynow+Math.sin(2*Math.PI*(xnow/50))*10) + "px"; setTimeout(animate,20); } Here I create a program for moving sine wave using jBRa...

 
Edge still doesn't support extensions
 
3:46 PM
or have ever try to retrieve based on the content-type ? @ssube
 
@JanDvorak Which extension?
 
All of them
 
@Lamar nah. I really just use it to store backups and as a distributed cache for binaries and build artifacts.
 
ok
 
m59
@ssube OH DOH
Flipping languages all the time :/
 
3:50 PM
adblock, *monkey
 
How do you usually test this kind problems when something doesnt work in defferent ie versions?
 
@BenFortune Nope; I'm moving away from OOP heavy code in my personal projects. I was working on something similar that was more procedural, but it's been a while since I've touched either
 
m59
I was stuck in JS mode where that would be concurrent =D
I am a big dummy
 
So in mongodb, if I wanted to post something to say "localhost:3000/add/1" and then access that at "localhost:3000/list/1", how would I do it? I'm kinda on the right track I think, but I'm not even sure what to google to figure this one out... This is my post:
router.get('/list/:id', function(req, res) {
	var id = req.params.id;
    req.db.get('usercollection').find({},{fields: {"_id":0,"mcr":0}},function(e,docs){
        res.json(docs);
        //console.log(docs);
    });
});
 
@WaterlessStraw p.sure that's a GET :P
 
3:53 PM
whoops wrong one :p
router.post('/add/:id', function(req, res){
    var db = req.db;

    var collection = db.get('usercollection');

    collection.insert({
        "mcr":"relationship",
        "info" : req.body
    }, function (err, doc) {
          res.send(
            (err === null) ? { msg: '' } : { msg: err }
        );
    });
});
 
You probably want:
 req.db.getCollection('usercollection').find({
   _id: req.params._id
 }, {
   "_id": 1,
    mcr": 0
 }, (e, docs) => {
  e ? next(e) : res.json(docs)
})
 
@ssube Which comment? I make a lot of them from time to time.
 
it is customary to respond with the document you've just added
especially if adding it to the DB adds more fields, like dateCreated and lastUpdated
 
the ._id is created by mongo by itself, id would be different and would be specified in the POST, id could be written as something else
Unless there is a way to override that?
 
You can set the _id to anything as long as it is unique
 
3:59 PM
you shouldn't mess with _id or use it for much of anything, though
it's an internal thing and can change if mongo wants (at least in older versions)
 
Thats what I was thinking...I read somewhere not to mess with it. I feel like I just need to do something along the lines of req.params.id, which is different than _id, correct?
 
use your own id and put an index on it
 
right, that is what I am trying to accomplish. Just not sure how to go about it or how to google it :p Like, posting to add/1, I can access that same JSON from list/1. And same with add/2 and list/2
 
this might be helpful for doing something like that. Alternatively, you could create a readable slug like corvid-123
 
user image
3
Netflix needs to chill
 
4:05 PM
@SterlingArcher "Because you liked Hitler and the Nazis"
lol
 
oh the irony
 
@SterlingArcher Don't you have a demo to get ready for that's in less than an hour?
 
It's all set as best as I can get it. I'm eating a salad now lol
 
@SterlingArcher Smart man.
 
@SterlingArcher Hitler was a vegetarian
 
4:11 PM
Hitler did 9/11
 
7/11 was a part time job
5
 
@SterlingArcher Bush killed Hitler
Bush is Hitler
 
Hillary is Hitler
 
People give him lots of flak, but at least he killed Hitler
 
4:14 PM
@SterlingArcher God, I love that movie so much.
 
I saw it very drunk and I couldn't handle it lol
 
@SterlingArcher I was not sober when I watched it and my roommate got home halfway through and said I was sitting dead still on the couch with my mouth hanging open.
so I started it over and he had about the same reaction
 
@SterlingArcher LOL I love that movie man
 
lmao it was something else
 
it felt a lot like Hotline Miami, especially with the rgb split around the edges of stuff
 
4:29 PM
has anyone ever got a years old post randomly down voted haha?
 
@rlemon Did you ever finish that userscript manager extension thingamajig you were making?
@GNi33 cringes
 
Does JSFiddle have a public API for creating a new JSFiddle link with AJAX? I'm looking for a way to fork a jsfiddle from within its demo.
 
@PatrickRoberts programmatically from the demo?
 
LOL
laughed out loud for real at that
 
Hey !
 
@DeltaWeb Welcome to the JavaScript chat! Please review the room 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.
 
Ho !
Let's go!
 
Okay
Guys, I can't find on how to copy a string to clipboard automatically ?
 
4:50 PM
Na na nana da na, na na nana da duh
 
Any help ?
 
@DeltaWeb can you try googling first? "javascript clipboard api" -- I mean, come on... put in some effort.
 
for the record that was third link on google search "javascript clipboard"
 
@ndugger , Yes, but I need some help in aking this automated .
 
4:54 PM
@PatrickRoberts But Pat, Googling is haaaaaaaaaard.
 
I really hate cucumber...
 
@Megaplex correct!
/me hands @Megaplex an internet cookie
 
@SomeKittens How about a better job instead. :P
 
Jesus. Just read this... if you haven't already. github.com/bibanon/bibanon/blob/master/Stories/…
 
tl;dr
 
4:58 PM
If you were going to build a desktop app with js, what would you use electron.js or NW.js ?
 
element.scrollTo(0, document.body.scrollHeight); This seems to work perfectly fine in Firefox. But both IE and Chrome complain that scrollTo is not a funtion?
I've got the tip from this question: stackoverflow.com/questions/11715646/…
 
I've never heard of NW, so I'd say electron
 
@ndugger no, read it
 
make me
 
@icecub isn't scrollTo only available on the window?
 
5:01 PM
@ndugger again?
 
@icecub stackoverflow.com/a/33193668/1541563 this is probably the best answer if you want total support
 
you'll have to increment the scrollTop value of the element, so element.scrollTop = 10
(iirc)
 
@bitten I wasn't sure about that. But it seems to work fine on Firefox. So either firefox is a bit relaxed about it, or both IE and Chrome are behind on its functionality
@PatrickRoberts Thanks I'll have a look at that :)
 
Okay, thank's patrick :)
 
@icecub yeah, that sounds about right..
mdn reflects this idea also
see difference in URL
 
5:06 PM
Ah, so it seems Firefox is a bit relaxed about it. I wonder if that was done intentionally though, haha
 
yeah, interesting
love browser quirks
 
has anyone here worked with gulp and babel? i'm getting a weird error in one project, but not in others that should be setup exactly the same way...
 
@DeltaWeb i want to build a small desktop app in js and i was looking at electron
@NathanJones i'm using gulp and babel right now, what's up?
 
Yes electron.js looks better
 
@bitten i'm using gulp-babel to build a project that runs in the browser, but i also want to use babel to compile my gulpfile.js file
//the problem is I get this error when i try to build
[11:06:28] Requiring external module babel-register
/home/nathanjones/Projects/extended-schema-client-library/gulpfile.babel.js:1
(function (exports, require, module, __filename, __dirname) { define(['gulp', 'gulp-ps-tasks'], function (_gulp, _gulpPsTasks) {
                                                              ^

ReferenceError: define is not defined
    at Object.<anonymous> (/home/nathanjones/Projects/extended-schema-client-library/gulpfile.babel.js:1:63)
 
5:09 PM
Any good reads about building an MVC app with JS ?
 
i thought gulp can use es6 now
 
Without using frameworks like angular
 
@bitten i'm using es6 module syntax in my gulpfile, so i think i still need babel?
 
@NathanJones well you should just be able to run it
have you named your file gulpfile.babel.js? last time i was looking into it that should be all you need
 
the problem is the gulpfile.babel.js is getting compiled to AMD module syntax, which i don't want for node, but i want that for my project code that babel will compile for the browser
 
5:11 PM
@NathanJones is this the same problem you (or somebody similar) had a while back?
where you were using the AMD modules globally in .babelrc
 
@ssube yep, same problem, and that was me.
 
because that will not work
 
Well at least its fully working now. Thanks again @PatrickRoberts
 
@NathanJones here, check this out as a reference: gist.github.com/stephensauceda/ce81e95c6f6c5747d8aa
 
@ssube i have projects that build just fine with amd included in the .babelrc file
 
5:12 PM
it's a year old but it checks out
 
For mongo, if I want replace an already existing object at the specified path, how would I modify this could so that it does?
router.post('/add/:id', function(req, res){
    var db = req.db;
    var id = req.params.id;
    var collection = db.get('usercollection');

    collection.update({
    	"id" : id,
        "mcr":"relationship",
        "info" : req.body
    }, function (err, doc) {
          res.send(
            (err === null) ? { msg: '' } : { msg: err }
        );
    });
});
 
@NathanJones it will cause babel to use AMD modules, which don't work with gulp.
You need to move the amd plugin out of your global babel settings and into just the source compile.
 
@ssube and i also updated my gulp task to explicitly use AMD
 
what do your babel settings look like now? (all of them, babelrc and within gulp)
 
i also get this error when i use the commonjs plugin in .babelrc
i'll make a pastebin with all of my settings
 
5:15 PM
@WaterlessStraw don't use Mongo
really, don't
please learn from my mistakes
 
too late, its just for a small REST app. Are you using rethinkdb now?
 
@WaterlessStraw literally anything is better than mongo, including flat files
 
I'm just an intern and they've asked to use mongo for this, and this is the last thing I need so I gotta stick with it
 
@WaterlessStraw postgres, though Rethink is nice (but I haven't used it much)
 
@ssube ouch
MSAccess it is
 
5:18 PM
@Loktar ok, msaccess might be worse, but it's close
 
hahah
 
at this point, msaccess hasn't crashed prod and mongo has...
but we don't use msaccess yet
 
Guys how to return the filename in this URL ? dropbox.com/s/2s10zza2npw7oxs/…
 
2 hours ago, by ssube
embrace the futility and despair of the end times deploy mongodb buy oracle vote trump
 
5:19 PM
@somekittens If I ever do a personal project, I'll look into something else. Probably rethinkDB as I've heard great things about it. Eitherway, any idea what I can do to just overwrite an existing object in POST?
 
@WaterlessStraw you want an upsert rather than insert
 
@ssube i must be missing something obvious
 
@NathanJones Hi Missing Something Obvious, I'm Megaplex.
 
initially i did have amd set, but i switched it to commonjs and i still get the same error.
 
@NathanJones why are you forcing a module style in babelrc at all?
 
5:24 PM
...i don't know
 
@ssube haha
some day you will die and all of this will be somebody else's problem https://t.co/KDbGmyF5e1
omg
hahah
 
If ExpressJS/NodeJS cannot handle multiple POST requests from the same route, does this mean I have no way of having 2 forms on the same route/page?
 
aw black humour is so great, i don't know why
 
@SvetanDimoff you can't have 2 forms submit from the same page normally
not if you're using actual forms (JS can do it)
 
@ssube don't i need to specify what module system to use for my gulpfile.babel.js in my .babelrc? i tried deleting my .babelrc and now i get (function (exports, require, module, __filename, __dirname) { import gulp from 'gulp'; SyntaxError: Unexpected token import
 
5:28 PM
@ssube I have a login/registration form on the same page and each time I log in I get a null row inserted in my database, so the registration form kicks off as well. app.use('/', function(req,res){//create the user}). The issue comes from the express route
 
@NathanJones that means babel isn't running at all
and no, you don't
babel will turn import into require by default
 
hello
what do you think about it?
you can create box with it
you don't MUST use px or #
 
@ssube it does say it's Requiring external module babel-register
 
@littlepootis Thank you
 
@NathanJones that is gulp loading babel. What else does it say?
 
5:30 PM
@littlepootis Truth be told, as someone who's worked in a government building, I can totally see this.
 
[11:30:07] Requiring external module babel-register
/home/nathanjones/Projects/extended-schema-client-library/gulpfile.babel.js:1
(function (exports, require, module, __filename, __dirname) { import gulp from 'gulp';
                                                              ^^^^^^
SyntaxError: Unexpected token import
    at Object.exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:513:28)
    at loader (/home/nathanjones/Projects/extended-schema-client-library/node_modules/babel-register/lib/node.js:158:5)
 
@Rain i.sstatic.net/exxgY.png no I can't. Why?
 
@ssube sorry for the pastedump, but that's all it gives me
 
wut?
 
5:32 PM
maybe i'm missing a global package i should've installed?
 
it npt work why?
 
in background you must put red or #000
(like standard
borderradius without px
like 10p
 
i did npm i -g gulp babel babel-cli babel-register
 
10*
not 10px
 
I want a 9cm border radius
 
5:33 PM
rotate like 5, not 5deg
@littlepootis
 
I asked it to rotate, though.
I said "YES"/
:/
 
my thought is.. what's the point of it? it makes a box,
 
> An accessible website is a site more usable for everyone
 
you don't must use YES
you can't use it
 
I'm drank and it's not accesible for me fix it
 
5:34 PM
now i fix ti
it*
 
the box also covers the button... so i can't regenerate it
 
@NathanJones looks like you're missing the es2015-modules-commonjs plugin
 
@NathanJones babel-register shouldn't be global
babel and babel-register should be installed to the project
 
Mm and gulp too, I guess.
Install gulp-cli globally.
 
@ssube local install didn't help
@FilipDupanović fixed, local install of that plugin didn't fix it either
(function (exports, require, module, __filename, __dirname) { import gulp from 'gulp';
^^^^^^
SyntaxError: Unexpected token import
is what i'm getting
 
5:38 PM
babel's not properly installed
 
there would be a module error then
 
yeah, it's a problem with babel not running at all
@NathanJones do you have anything besides the comonjs plugin in your babelrc?
 
@NathanJones can you just drop a quick .babelrc next to your build script, just in case it's an issue with Babel's configuration
 
@FilipDupanović he already has. Read the logs.
We've been over the commonjs plugin and how it's not helping.
 
I thought @NathanJones said something about deleting his configuration file
 
5:40 PM
@NathanJones if your pastebin is anything to go by, you have babel disabled in the babelrc
because you haven't enabled es6 at all
 
@ssube i thought you could enable a single plugin without having to include a preset?
 
use the es2015 preset without any of the module plugins
@NathanJones but babel won't do shit if you have es2015 disabled
 
13 mins ago, by Nathan Jones
@ssube don't i need to specify what module system to use for my gulpfile.babel.js in my .babelrc? i tried deleting my .babelrc and now i get (function (exports, require, module, __filename, __dirname) { import gulp from 'gulp'; SyntaxError: Unexpected token import
 
use the preset without the plugin
 
if you're on node 6 all you need is the modules plugin..
 
5:41 PM
i'm on the latest node (v6.2.1)
 
@cswl you don't need the module plugins
 
@NathanJones you just need transform-es2015-modules-commonjs then
{
  "plugins": ["babel-plugin-transform-es2015-modules-commonjs"]
}
 
adding the preset seems to have worked...
 
@FilipDupanović you do not need any module plugins
by default, if you have es2015 enabled, babel will transform import into require
 
if the preset includes the plugin you would be including
 
5:44 PM
you can see that in the repl, you can see it everywhere
all you need for gulp to use babel is the es2015 preset
 
@ssube that comes with the es2015-preset, but it doesn't transform jack if you don't configure it first @NathanJones
 
@ssube right, but if the only feature i'm using out of the es2015 preset, should i be able to include the commonjs plugin and it will still work?
 
@NathanJones no. import is an es2015 keyword.
 
so plugins don't work unless you also include the preset?
 
5:45 PM
@NathanJones do not use the whole es2015 preset for Node 6
 
AMD/commonjs modules have almost nothing to do with import existing in the language
you can use neither/both/either/or
 
you only need babel-plugin-transform-es2015-modules-commonjs, the rest you can leave alone; Babel doesn't do feature detection
 
using es2015 preset on node 6 doesn't make much sense.. all you need is module transform to whatever system you're using..
 
what is this "enabling es2015"? @ssube
 
node 6 still doesn't support import
you need to transform import into require, which is part of the 2015 preset
you may not need the rest of the preset, like @cswl said
 
5:47 PM
@ssube i hate to be idiotically pedantic, but isn't the commonjs plugin a subset of the 2015 preset? why would including the preset which includes the commonjs plugin work, but only including the commonjs not work?
i mean, the only other feature that (i think) i'm using that comes with the preset is arrow functions, but that's supported in node6
 
no, it's more than that, the preset is huge babeljs.io/docs/plugins/preset-es2015
 
presets are just a bunch of plugins... you can make your own too.. for node 6 you can use this preset.. which basically is transform-es2015-modules-commonjs github.com/Salakar/babel-preset-node6/blob/master/index.js
 
@FilipDupanović i meant to say that i'm directly taking advantage of
 
es2015-preset by itself is way bigger even for what you'd need in Node.js 5.x
@NathanJones it should have worked; blame it on a misplaced or odd configuration file?
 

« first day (2062 days earlier)      last day (2904 days later) »