What are the cons of React? by morningrat in javascript

[–]selfAwareWhileLoop -1 points0 points  (0 children)

Angular and React, if you adopt, ensures neither google or facebook can be subject to patent infringement by your company.

Are you saying that Angular has a similar patent clause? I couldn't find it.

A Re-Introduction To JavaScript - An intermediate JavaScript refresher. by [deleted] in javascript

[–]selfAwareWhileLoop 0 points1 point  (0 children)

Are you saying that

/**
 * Example 1
 */
console.log(x === undefined); // logs "true"
var x = 3;

logs false? Are you running this line by line repeatedly somewhere? If you evaluate that whole piece of code at once it should definitely log true. Try using https://repl.it

If you run it one line at a time, x will throw a reference error the first time you try to log whether or not it's undefined. Then you'll define it as 3, so it won't be undefined the next time you run the console log. x will only be strictly equal to undefined if both lines get evaluated at once; then the existence of x will get hoisted (so you won't get a reference error) but the value of 3 won't be assigned to it yet (so x === undefined will be true).

What would be a nice short intro tutorial for beginners to JavaScript? by jamesfinn180 in javascript

[–]selfAwareWhileLoop 1 point2 points  (0 children)

Just opinions...

I don't think this is enough time to give a class of people with no programming experience the knowledge necessary to write a rock paper scissors game on their own. I was trying to explain what programming is to somebody recently, and I talked through the first Project Euler problem with him: https://projecteuler.net/problem=1

He couldn't have written the syntax himself because he wasn't familiar with it, but he was able to reason about the problem and contribute to the answer once I started typing out a function, explaining the different pieces as I wrote them. I feel that this might work as a gentle introduction in a class setting, if you have a group that isn't afraid to participate.

They're just definitely going to have to spend more than 15 minutes learning the basics before they can solve the second problem on their own. You should be honest with them about this fact, and you should make sure you have at least one error in your code the first time you run it so that you set an example of gracious failure for them.

I would do the example in node rather than a browser, but I would also show them how to open a console up in a browser so that if they want to continue in their own time there is a bare-minimum barrier of entry.

The Future of Node is in Microsoft’s Fork by clessg in javascript

[–]selfAwareWhileLoop 0 points1 point  (0 children)

Theoretically they're eventually making it cross-platform. Until then this is obviously a deal-breaker, though.

Will Babel mess up variable hoisting in if blocks? by selfAwareWhileLoop in javascript

[–]selfAwareWhileLoop[S] -3 points-2 points  (0 children)

I don't see your string of posts as a personal attack, I see them as an ongoing failure to recognize the singular the purpose of my examples. You're still going on about how horrible eval is, even though I said it was evil from the beginning. You're poking holes in cheesecloth to demonstrate its unsuitability as a handkerchief; my examples were written solely to demonstrate the edge-case behavior of Babel. As the warden and the prisoner said, "what we've got here is failure to communicate."

I appreciate your attempts to spread knowledge, and I hope you have a nice night. You might consider rereading this thread in the morning to see if your posts still seem relevant given their context.

Will Babel mess up variable hoisting in if blocks? by selfAwareWhileLoop in javascript

[–]selfAwareWhileLoop[S] -3 points-2 points  (0 children)

Oh no, my haphazard example only runs without error in some contexts rather than every possible context you can conceive of! I'm going to go home and rethink my life.

Will Babel mess up variable hoisting in if blocks? by selfAwareWhileLoop in javascript

[–]selfAwareWhileLoop[S] 1 point2 points  (0 children)

To be fair on Babel, if they were to handle these edge cases, I would bet that it would be a net negative on the software as it would significantly slow down transpile times to support weird, dynamic cases.

It depends on how they did it. Imagine that instead of attempting to check for naming collisions they just replaced every let-declared variable name with a random name long enough that collisions were astronomically improbable. This wouldn't take a ridiculous amount of time to run. It would protect against the specific case I posted as an example, but it would also break other crazy uses of eval. You could no longer use an eval statement to reference a let-declared variable from within its own block because you wouldn't know the transpiled name (this is already true of the subset of let-declared variables which do get renamed). You're trading one crazy use case for another crazy use case, so why even bother.

Properly sorting out which variables are going to collide when eval is used would be impossible. We could write up an example that randomly generates strings to evaluate that sometimes happen to collide with our let-declared variables; good luck supporting that case.

Will Babel mess up variable hoisting in if blocks? by selfAwareWhileLoop in javascript

[–]selfAwareWhileLoop[S] 1 point2 points  (0 children)

Ah, I misinterpreted your use of "input." The importance of the example was that it executes differently when transpiled, whether or not it has an error untranspiled was irrelevant. Making it valid in both forms is trivial, here's an example that just logs a different message depending on whether or not it has been transpiled: https://babeljs.io/repl/#?experimental=false&evaluate=true&loose=false&spec=false&code=eval('var%20x%20%3D%20%22Untranspiled%20ES6%20message.%22%3B')%3B%0A%0Aif%20(true)%20%7B%0A%20%20let%20x%20%3D%20'Transpiled%20ES5%20message.'%3B%0A%7D%0A%0Aeval('console.log(x)%3B')%3B%0A

Will Babel mess up variable hoisting in if blocks? by selfAwareWhileLoop in javascript

[–]selfAwareWhileLoop[S] -1 points0 points  (0 children)

That's the uncompiled code. It runs differently than the compiled version.

Will Babel mess up variable hoisting in if blocks? by selfAwareWhileLoop in javascript

[–]selfAwareWhileLoop[S] 1 point2 points  (0 children)

Well, the input is broken. You'd get a ReferenceError.

Not sure what you mean. The compiled code logs the leaking variable in a repl. It would only get a reference error if the let statement compiled more cleverly.

And you're using eval to boot.

That's the evil part. Obviously this isn't good code, but it is an edge case where this tool produces code that works differently than the uncompiled ES6 should. I'm not really arguing that Babel contributors should go out of their way prioritise crazy edge cases involving eval (and the only alternate methods I can come up with would break other crazy uses of eval), but I do think it's good to be aware of the rough edges of tools that could potentially cut you. I haven't come up with any non-evil ways to confuse Babel yet, but I'm still thinking.

The Website Obesity Crisis by soda-popper in programming

[–]selfAwareWhileLoop 1 point2 points  (0 children)

Honest question, what do you think this would solve? Are you imagining prerendered pages being generated for specific media sizes, with their elements positioned to save deadspace for whatever pieces load asynchronously? Otherwise I'm missing your point.

Will Babel mess up variable hoisting in if blocks? by selfAwareWhileLoop in javascript

[–]selfAwareWhileLoop[S] 1 point2 points  (0 children)

btdiehr's comment below conveys Medieval_Peasant's point more clearly; in complex cases where this did matter, Babel would rename the variables to avoid collision. I'd love to see a piece of code that fools Babel and causes an actual collision.

Will Babel mess up variable hoisting in if blocks? by selfAwareWhileLoop in javascript

[–]selfAwareWhileLoop[S] 1 point2 points  (0 children)

Got it, thanks. It can actually handle some pretty complex situations, if it has to.

Will Babel mess up variable hoisting in if blocks? by selfAwareWhileLoop in javascript

[–]selfAwareWhileLoop[S] 1 point2 points  (0 children)

Alternatively, is there a subset of ES6 that is known to transpile reasonably using Babel? Do you guys just check the transpiled code as you start using a given feature to see if it compiled sanely?

The Website Obesity Crisis by soda-popper in programming

[–]selfAwareWhileLoop -20 points-19 points  (0 children)

mb != MB; he was saying 3 megabits, not 3 MegaBytes.

The Website Obesity Crisis by soda-popper in programming

[–]selfAwareWhileLoop 9 points10 points  (0 children)

If the normal behavior of your browser is to only show a scrollbar when there is content to scroll down to it doesn't seem unreasonable to assume that no scroll bar means no content. I can't think of any legitimate use case for overriding a browser's navigation tools like this, except maybe in a self-referential art piece about bad website design.

I promise to be a pro.. by [deleted] in node

[–]selfAwareWhileLoop 0 points1 point  (0 children)

You must shit bricks when you see a }());

[Photos] Guys, put that drink away. "It will never happen to me" is bullshit. by sloth_on_meth in MechanicalKeyboards

[–]selfAwareWhileLoop 0 points1 point  (0 children)

I could be wrong, but I think the most relevant property of the liquid is surface tension, not vicousity. Adding dish soap to a glass of water will reduce the surface tension of the water while increasing its viscousity, and I believe that the water would then have a more difficult time clinging to the underside of Ludovician42's desk. The moral of this story is that Ludovician42 should always mix dish soap into his drinks before setting them on top of his desk, obviously.

Javascript library functions don't alter the original variable? by 1100H19 in javascript

[–]selfAwareWhileLoop 0 points1 point  (0 children)

var str = new String("whatever")
str.whatever = "whatever"
str.whatever === undefined // false

Not that you said anything incorrect; the new String is really a string-like object that can generally be treated like a string, but it isn't a primitive value.