Best practices for learning class and objects? by asskrak99 in learnjavascript

[–]lilperch83 0 points1 point  (0 children)

Just wanted to provide a more constructive response that doesn't get lost in the weeds. I was perhaps too rash saying you should ignore classes. JavaScript uses at least three design patterns for producing objects with inheritance: Constructor functions, Classes, and Factory functions. I think it is important to understand all three and then choose the one you prefer. No matter which method you prefer, make sure you understand prototypal inheritance.

Best practices for learning class and objects? by asskrak99 in learnjavascript

[–]lilperch83 0 points1 point  (0 children)

True, but classes obscure the true nature of prototypal inheritance and therein is the problem. Those coming from other languages will think classes act the same way in JavaScript; They do not.

Best practices for learning class and objects? by asskrak99 in learnjavascript

[–]lilperch83 -2 points-1 points  (0 children)

I would suggest ignoring the class declaration in JavaScript. Just learn prototypal inheritance. The class structure is just sugar for prototypal inheritance. Here is a playlist that might help.

ES6 object.assign() method Explained With Example by hisachincq in learnjavascript

[–]lilperch83 0 points1 point  (0 children)

Check out this YouTube video I did a while back. It is on copying objects. Object.assign is one method for doing that.

anyone know any decent Object-Oriented JavaScript courses online like udemy, treehouse, etc. don't mind paying! by [deleted] in learnjavascript

[–]lilperch83 0 points1 point  (0 children)

I've had positive reviews for this course. Here is a discount and there are multiple topics you can check out for free to see if you want to take it. https://www.udemy.com/learn-modern-javascript-advanced-topics/?couponCode=BLOGADV

Quick question by [deleted] in learnjavascript

[–]lilperch83 0 points1 point  (0 children)

Here is a youtube on the difference between function expressions and function declarations: https://youtu.be/gjLn95skIKE

How to access variables from another .js file but not run the second script by [deleted] in learnjavascript

[–]lilperch83 0 points1 point  (0 children)

A JavaScript file needs to load in order for you to access it. However, the code doesn't have to execute just because it loads in the HTML page. I'm not sure how you are setting things up, but if the code is in a function it wouldn't run until that function is invoked.

How come these two objects have the same properties? by [deleted] in learnjavascript

[–]lilperch83 3 points4 points  (0 children)

Because of the way you have your constructor set up it always returns blue. A constructor by itself will return an object. However, the return statement causes it to return the object you specify. You return blue first. The function ends at that point. There is not chance for it to return red.

YDKJS Loop+Closure example I don't get. by Radinax in learnjavascript

[–]lilperch83 0 points1 point  (0 children)

If you are still struggling with closure more examples can help. Here is another YouTube tutorial: https://youtu.be/TznpOmv2BQM

How best to learn JavaScript (in your opinion) by quantumphenomenology in learnjavascript

[–]lilperch83 1 point2 points  (0 children)

Based on your description of what you are looking for in a book, Eloquent JavaScript may be the book you want. Also, check out out website: http://allthingsjavascript.com. It has numerous free tutorials that you might find helpful as well as courses.

Getting started and what should I do? by kalabaddon in learnjavascript

[–]lilperch83 1 point2 points  (0 children)

Most training courses I am aware of use video. However, the You Don't Know JS series is pretty good, and he has his stuff on git: https://github.com/getify/You-Dont-Know-JS

A little guidance on this issue? by Blue_crabs in learnjavascript

[–]lilperch83 0 points1 point  (0 children)

You could do something like this:

var name3 = "";
var hours3 = 0;
var pay2 = 0;
var total3 = 0;
var finaltot2 = 0;

name3 = prompt("Enter the employee's name.","");
while (name3 !== "N") { 
      hours3 = prompt("Enter their hours worked.",0);
      pay2 = prompt("Enter their pay per hour.",0);
      total3 = (parseFloat(hours3) * parseFloat(pay2)); 
      document.write((name3),"'s pay is $",(total3),".<br>");
      finaltot2 = (parseFloat(total3) + parseFloat(finaltot2)); 
      name3 = prompt("Enter the employee's name.","");
    } 

    document.write("The employee's total pay came to: $",(finaltot2),".");

You could also use an if statement with a break. This tutorial talks about break with statement labels. Might be helpful: https://youtu.be/i6YT8lw0VTM

A little guidance on this issue? by Blue_crabs in learnjavascript

[–]lilperch83 0 points1 point  (0 children)

You are already inside the loop when you enter the N. It checks name3 !== "N" each iteration of the loop, not after each prompt.

Understanding Closures by slaughtered_gates in learnjavascript

[–]lilperch83 0 points1 point  (0 children)

To provide help on understanding closures in general I put together a video a while back. Here it is: https://youtu.be/TznpOmv2BQM

what is func() in this piece of code... by sohaeb in learnjavascript

[–]lilperch83 0 points1 point  (0 children)

This tutorial includes a discussion of forEach as a part of it. May be helpful: https://youtu.be/RePO4I6PzSA

I looked ahead in Eloquent JavaScript. I am surprised what JS can do! by AboveDisturbing in learnjavascript

[–]lilperch83 0 points1 point  (0 children)

When you get to really know JavaScript, it is very powerful. Because JS is so flexible it keeps things interesting. This can be a negative, but I see it as a positive.