« first day (2369 days earlier)      last day (2804 days later) » 

user1596138
23:00
In almost all Front End dev that's not an issue. There are platform specific packages of course
user1596138
But generally speaking there is no difference
i know!!
@SterlingArcher I do, but its all jQuery. The docs didn't help either developer.mozilla.org/en-US/docs/Web/API/element
thanks for your input guys
43
Q: Javascript detect if input is focused

southpaw93How do I detect when .click event triggers if textarea is already focused? I have this javascript: $(".status").on("click","textarea",function(){ if ($(this) == "focused") { // fire this step }else{ $(this).focus(); // fire this step } T...

second link fam
Even the first link has a non-jQuery answer in it
user1596138
23:02
834
Q: How do I find out which DOM element has the focus?

Tony PetersonI would like to find out, in Javascript, which element currently has focus. I've been looking through the DOM and haven't found what I need, yet. Is there a way to do this, and how? The reason I was looking for this: I'm trying to make keys like the arrows and enter navigate through a table of ...

user1596138
This one isn't a bunch of jQ either.
You guys are way better than google. You put the answers through "extreme vetting".
I was looking to see if an element object had a .isSelected or .isActive
no, gotat compare it to the document property
user1596138
Why would the element know that it's focused
23:04
Was asking the wrong question, but I did go to the docs first.
user1596138
The parent cares what it's focus is on :P
well, it has a focus() method and a focus/blue event, so an isFocused prop isn't that crazy of a thought.
user1596138
On it's prototype it does
user1596138
I'm not gonna argue this one :P made sense differently in my head
After reading stuff like ndugger.github.io/youdontneedjquery I'm trying to slowly break my reliance on JQuery.
23:06
How can I delete the object *and* its properties?
...
obj[key][val] ...
ex: delete obj[key];
if I link again to the same key the property val will still be there,
should I do: obj[key] = []; and then delete it?
user1596138
@jake Are you a regular or did you get that link all on your own?
he's around enough recently.
few months now at least
cut up my lights.. built the box.. pulled out my soldering iron. forgot, no tip
fml
I'm a wannabe regular.
fetch('/path/to/json')
.then(response => response.json())
.then(data => {
    // use 'data' here
})
.catch(error => {
    // use 'error' here
});
@nonerth you can delete properties from objects and that's it. Also, there is no need to assign them first (like the obj[key] = [] is useless)
23:08
Since arguments are evaluated first, can't you just compress this into
fetch('/path/to/json')
.then(data.json() => {
    // use 'data' here
})
.catch(error => {
    // use 'error' here
});
I was under the impression that the delete just -un-links- the key from the property while the property values still remain
.json() returns a promise.
and I want to delete the properties and the key as well
23:09
@SterlingArcher no, you are NAMING args in the function siganture
also, not sure if that'd work..
because ^^
But you can assign values in a functions parameter, no?
@SterlingArcher what you'd want to be possible is .then((data = data.json()) =>
and have that assigned to itself somehow
@nonerth if there are other references to the value object, then yes, it stays, but it should stay as a property value on the item you deleted it from
think about it for a second
it can't work
23:10
though, some deletes can silently fail, i think, it they are not reconfigurable
fetch("/the/number/four").then(x = response+4 => { ... });
yeah that
@SterlingArcher You can do something really, really hacky
@SterlingArcher but you're asking for x=> x+4
which needs x to first be undefined
....
oh uhm, so perhaps I should assign an empty array just to be sure in case it fails?
fetch(...).then((data, json=data.json()) => json)...
user1596138
23:11
Default arguments
nonerth or undefined.
user1596138
@Zirak got it
But that begs the question: Why would you do these things?
reduce chaining in this case? :P
btw I still want to completely empty the prop value cause later on I use the same key so.. yeah
23:11
but it should only fail on objects that are locked down, not your normal object you created in your own code
const res = await fetch(..);
const json = await res.json();
return json
Have a fetchJson utility
Now, is .json() returns a promise, wouldn't you still have to await on it?
thats nice to hear then
@SterlingArcher it's beautiful with async/await
23:12
I love async await
@rlemon You can drop the json variable
but I like it
you want res for other things
You can also drop the res variable
23:14
like response.status
return await (await fetch()).json()
you just lost the status
yea, because that's soooo readable.
await await await await await
meh
23:15
That reminds me
0
Q: Are there performance concerns with `return await`?

sfletcheI see there is an eslint rule, no-return-await, for disallowing return await. In the rule's description, it states a return await adds "extra time before the overarching Promise resolves or rejects". However, when I look at MDN async function docs, the "Simple Example" shows an example contai...

this question confused me, why would eslint say return await is bad?
it's redundant, since an async function returns a promise regardless.
but i do it sometimes for clarity.
const getJson = async url => await (await fetch(url)).json();
@Zirak would you want that in your codebase?
So @Zirak's code can even further become await (await fetch()).json() and that implies a return?
@rlemon I honestly wouldn't care
yea, you can drop 1 await, i am pretty sure.
const getJson = async url => (await fetch(url)).json();
23:18
I don't think so, would 1 await apply to both promises?
you don't need to await the .json(), because async functions return promises already
no, but whatever you return from an async function is 'awaited' when the caller awaits this result
@Luggage yeah you're right, I was thinking about using the result then and there, not in a chain
is what Luggage is pointing out
ohhh
So it would still end up being getJson().then(
gotit
23:20
await getJson()
exactly.
await DEATH; // death is global and constant
const antly = await ingDeath();
JS puns are fun
nerd
I was toying with the idea of making a super-null object
brb best of Al Bundy insults
23:23
like a black hole value?
Imagine an object which every property access returns superNull
with a value-horizon
And perhaps even act as a function
like a universal "noop" object?
So like NaN is the propagation value for arithmetic, superNull is the constant value for object access
23:24
i wonder if you can make a proxy that is callable
@Luggage More like something where it doesn't matter if it's null or not, you can still access properties and call methods and it'll just return superNull
Huge plus if it's also falsy
@Luggage Only if the target is callable
so, one object has SOME superNull props, but those values are all super-null on every key?
so like, const foo = Zirak(); foo.anything().I().want() === superNull?
yeah
foo.user.name.first (is user is supernull, then it all resolves to supernull)
23:27
I actually can get that part to work, I just can't make it falsey
Haven't though about it too much though
one sec
window = new SuperNull();
How do you create a function that takes an input, adds callable dot-methods to it, and returns the original value with the dot-methods? (Oh, and without using the new operator)
Then you can change the declaration to be char. If this answer is helpful, can you please mark this as the answer. Thanks. — Krishnanshu Gupta 4 mins ago
@Maxwill just like you said.
hate these comments
23:29
try it, and paste what you have
1 message moved to Trash can
@Maxwill Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
paste the code alone, indented by 4 spaces (CTRL-K)
Oh, formatting works in this?
Ok, let me re-write it correctly
if ALL lines of the textbox have 4+ spaces at the beginning, yes.
$ = function (_) {
  return Object.assign(_, { self: function () { return this }});
}
23:32
ok, that does what you say. adds a function "self" to the object you pass in (_)
and returns it.
Well, there's more
omg the tree fiddy episode is on
though, the particular method in your example is useless.
That's not the point.
If I input a string literal ("test") it outputs a string primitive (String)
const NULL = new Proxy(function ignore() {}, {
    apply() {
        return NULL;
    },
    get() {
        return NULL;
    }
});

NULL.foo.bar.baz().foo === NULL;
23:34
ohh, you are adding methods to a string?
@rlemon, @Luggage ^
The problem is that it's truthy
So you can't do if (NULL)
I want the truly unmodified string. and yes
Well, it's for all objects
I'm making a library called Javascript Mastery
@Maxwill Object.assign(Object(_), ...)
@Zirak but why
But that converts the string into an object
23:35
@SterlingArcher It's NaN for objects
@Maxwill A string object
A string primitive doesn't have properties so you can't add more
Can it?
oh
Doesn't a string literal have properties though?
@Zirak dammit
When you do 'string'.something it's actually translated to Object('string').something
I was fucking around and got here:
function Zirak() {
  const z = {
    get () {
      return Proxy({}, uhhh....);
    }
  };
  return new Proxy({}, z);
}
never used proxy objects before
23:36
@Zirak thanks for the insight.
so that was a quick mdn read
Somewhat of a small workaround could be to add a property with the original value
6
Q: Why are JavaScript primitives not instanceof Object?

Gary ChangToday I happened to have too much time to kill and I played a bit with the Node (v0.10.13) command line: > 1 instanceof Object false > (1).__proto__ {} > (1).__proto__ instanceof Object true > (1).__proto__.__proto__ === Object.prototype true Now, according to MDN, what instanceof does is: ...

For more info on the object wrapping
$ = function (_) { return Object.assign(_, { val: _ })};
So doing $("test").val will return the primitive
is that the closest I can get?
Depends on what you want to do
23:38
if you are making a library will take my string literals and give me string objects, i will be nervous about that causing issues.
i don't know that it will.. but that's my thought
I just want to use the string as the "this" operator for a bunch of functions
I could make it so that using $ returns a list of apply() functions
@Maxwill btw, an object wrapping a primitive value is exactly a string object
@Zirak wow nice answer dude
!!> function foo() { console.log(this) } foo.bind('hello world')()
@rlemon "function bound foo() {\n [native code]\n}"
23:39
TIL boxing
Just instead of thing.val you go thing.valueOf()
@rlemon "undefined" Logged: "hello world"
@SterlingArcher thanks
downvoted
23:40
Order has been restored
(not really) :)
@KendallFrey youtube.com/watch?v=ytZ5jxZOMaE :D:D:D:D:D
fuck yea!~!
wood!!!!
you got your prescription filled?
i love when you link me stuff i saw when it was uploaded :P
lol he's got wood
23:41
IT IS RELEVANT TO A RECENT CONVERSATION WE HAD!!
GAWD KENDALL
Nope, doing it now. Prescription.fill("Dymethyltryptamine", { milligrams: 200 })
@KendallFrey cough hipster
@rlemon oh right, forgot
i'm a dick aren't i
now I know I need white oak
if it's good enough for China, it's good enough for me
@KendallFrey It's really up to you. Some people can be peters, others can be dicks. It's kind of a personal preference
why specify the ethnicity of the oak? it's all the same on the inside
nahh, red oak is different on the inside. its gone on a spirit walk.
Most trees are black on the inside.
23:43
My neighbour's tree is green on the inside
😬 no one noticed my white vs native joke :(
@rlemon I took a glance at it
@rlemon It was noticed
@rlemon the emoji for a frowny messes with me lol
@rlemen Chuckled a little, smiled slightly
23:44
it's funny because I'm the inferior red oak.
hahahaha.. :dies a little:
@rlemon Oh man, I'm still not ginger! I've regenerated 10 times you'd think by now...
wat?
gingers are terrible people
@rlemon sorry, doctor who joke
I got it too late
matt smith annoyed me
23:46
horses are terrible people
everyone loved him
He was like... ehh...
I'm personally an eccleston fan
he was way too short lived a doctor
something something he must have flew United..
!!afk sorry
Of the doctor who I've seen (8.5, 9, 10, 11, 12)

Best to worst: 10, 9, 11, 8.5, 12
I went back and watched a bunch of the earlier ones when it was on netflix.
they hold up pretty well.
@Zirak did you see my wooden sword?!
so yes?
No?
7 hours ago, by rlemon
in related news I made a sword
wut!
for my 10 year old nephew.
23:51
That's so cool
it's made of wood ofc.
showed my brother today when he stopped by to pick up a powerline adapter, I think he wants a larger one for himself
Understandable
nice work!
thanks! it's just some scrap wood. I'll probably make some more for when he inevitably breaks it. they're fun to make
$0.50 in wood, scrap cloth.. $22 in spray paint. :D
but in reality I'll use the paint for other projects too, so it is basically $0 sword.
I also wanna try making a war hammer... but I think he'll hurt someone with it
You can probably bludgeon someone with a wooden sword
but it's lighter than a hammer would be.
just like hitting someone with a stick
a heavy-ish stick...
23:54
much lighter. and I've rounded the edges so yea, it'll be like a stick hitting you
it was very very dry spruce wood.
and spruce has a good temperament with kids
I've made a mallet from maple, and it's solid. and not even that big. it would hurt a lot more to get hit with
or was that a black lab, I am thinking of...
@Luggage I just meant it's relatively soft.
it would probably break before doing much damage
unless he like took a running stab at someone..
phone rings
23:57
No, this is not a duplicate. — jcarpenter 23 secs ago
>:(
So sassy
@SterlingArcher I've got an answer to your return await

« first day (2369 days earlier)      last day (2804 days later) »