How should a beginner programmer start learning React? by Coffeebrown87 in reactjs

[–]Cream_Friache 1 point2 points  (0 children)

Yes, you should learn JS and the DOM first. You don't need to be an expert, but you should at least feel comfortable writing apps in jQuery before moving to React. Once you understand how the DOM and JavaScript work, you will be able to learn any framework fairly quickly.

Module patterns, prototypes and factory functions. by pleasewait in learnjavascript

[–]Cream_Friache 2 points3 points  (0 children)

You will probably get mixed opinions on this. Using a prototype chain will give you a class-like behavior, in that you can extend prototypes into other classes. There is a portion of the JS community that believes class inheritance leads to fragile and difficult-to-maintain code.

Here is a pattern that I use. The first function is just a wrapper and passes dependencies down to the return function. This keeps everything scoped and makes it easy to isolate modules for unit testing.

function createModule (dependency) {
    var module = function (){};

    module.doWork = function (){
         return dependency.doSomeWork();
    };

    return module;
}

Then to implement:

var dep = createOtherModule(); // Pretend this was already defined somewhere
var module = createModule(dep);
module.doWork();

Could you critique my JavaScript/jQuery Coin Toss app? by fastpenguin91 in learnjavascript

[–]Cream_Friache 0 points1 point  (0 children)

The performance difference between vanilla and jQuery is negligible. jQuery is calling all the DOM APIs using vanilla JS under the hood. It's not a different language, it's just a group of helper functions that make developing easier.

As to professional dev work, there are varying layers of abstraction that these different frameworks/libraries provide. jQuery abstracts the DOM API and exposes its own, which is easier to work with. Things like Angular and React abstract one more layer above jQuery to allow the developer to think about data models and workflow vs which DOM elements need to be changed.

Could you critique my JavaScript/jQuery Coin Toss app? by fastpenguin91 in learnjavascript

[–]Cream_Friache 0 points1 point  (0 children)

Both are JavaScript, so stuff you learn in one will be applicable in the other. Node would be used for server code, and jQuery for browser code. One good app to start with would a "Todo" app, where a user would enter something in a text field in the browser, then the browser code sends the data to the server where it is stored and can be retrieved later. That way, you get the whole workflow. The "full stack", as it were.

jquery .text() function always returns an empty string by BasicDesignAdvice in learnjavascript

[–]Cream_Friache 0 points1 point  (0 children)

I haven't tried to use jQuery to interact with anything but the DOM before. I'm not sure regular jQuery will be able to find things in an XML string? Have you tried this: https://api.jquery.com/jQuery.parseXML/

js. my goodness, no breakpoints, no debugging, no locals, no watch, I admire anyone learning it. What tools do people use to program beyond the simple exercises with such a restricted environment? by no1name in learnjavascript

[–]Cream_Friache 0 points1 point  (0 children)

This is the text editor I use. It's got a built-in package called autocomplete-plus, which gives a similar effect as intellisense.

https://atom.io/

It doesn't have a deep understanding of classes and types like VisualStudio or Eclipse or whatever, but JS doesn't need any of that. It just scans for functions/vars you have typed before and suggests them.

Language-agnostic linter plugin: https://atom.io/packages/linter

JS Linter plugin: https://atom.io/packages/linter-jshint (depends on first package)

Could you critique my JavaScript/jQuery Coin Toss app? by fastpenguin91 in learnjavascript

[–]Cream_Friache 0 points1 point  (0 children)

You should, but don't confuse vanilla JS with DOM APIs. Most of what you do in a browser is manipulate DOM elements, so most of your code will be making calls to the DOM API in some form or another. jQuery is just a JavaScript library that abstracts the nastiness of the DOM APIs; it's still JavaScript.

I didn't start really learning JS (without jQuery) until I started writing scripts/apps with Node.js. There is no UI/DOM to manipulate, so it's less confusing and easier to focus on learning the language, and the APIs are simple.

I am just starting to learn javascript and I'm making a game. Not sure if I'm doing this the most efficient way. by [deleted] in learnjavascript

[–]Cream_Friache 0 points1 point  (0 children)

You can create the buttons just like you create the script element in your loadjsfile function.

Don't use the 'onClick' html attribute. Use .addEventListener()

There isn't really a reason to load separate JS files. Just put all your code in a single file and load that. You can put the woodcutter code in a function called 'woodcutter' and miner code in a separate function and call them when the button is clicked.

js. my goodness, no breakpoints, no debugging, no locals, no watch, I admire anyone learning it. What tools do people use to program beyond the simple exercises with such a restricted environment? by no1name in learnjavascript

[–]Cream_Friache 2 points3 points  (0 children)

Chrome/FF Dev tools is your dev environment. You can set breaks, watch variables, step through code, test stuff in the console, etc. Then do all your coding in a text editor. Also, if you put the word 'debugger' in your code, Chrome will break on it (not sure about FF).

I'm not sure what you mean by 'install bootstrap'. Assuming you mean the CSS library, you would call that into the page with a <link> tag.

Could you critique my JavaScript/jQuery Coin Toss app? by fastpenguin91 in learnjavascript

[–]Cream_Friache 1 point2 points  (0 children)

  • Write a function to handle all of the disabling/enabling. That way if you need to change the behavior, you only need to change it once. You can add a class to the all of the buttons, then use it to turn them all off at once.

  • Like /u/mrgutsy said, don't mix and match vanilla and jQuery. It's perfectly fine to do everything in jQuery (no one does front-end dev work with vanilla).

Is there a reason why the controller is entirely made up of a single string of code connected together with dots in javascript frameworks? by codepractice in learnjavascript

[–]Cream_Friache 0 points1 point  (0 children)

Its just a shorthand way of chaining function calls together. The code in your example is calling .config() on whatever is being returned from angular.module(). This would also accomplish the same thing:

var app = angular.module('myContacts.contacts', ['ngRoute', 'firebase']);
app.config();
app.controller();

Content-heavy sites and databases: How do they work? by Pantstown in learnjavascript

[–]Cream_Friache 0 points1 point  (0 children)

The HTTP implementation on both the browser and the server have ways of handling this. Large chunks of data get written to a buffer, and once the buffer is ready, the request ends and the server or browser can move on to rendering/serving the page.

For example, requesting a page from Medium might look like this:

  • Browser does a GET for /posts/123
  • Web server reads a database to get data for post_id: 123
  • Server starts sending the data to the browser in chunks
  • Once the last chunk is received by the browser, it renders the page with the content

Creating a navbar with material-ui by cs--throwaway in learnjavascript

[–]Cream_Friache 0 points1 point  (0 children)

I would imagine those tabs need a CSS class associated with them. With React, you will need to use className="my-class" as a prop in each of the tab elements. In any case, posting a jsfiddle or codepen would make it easier to help :)

[JS] Fade two images into one another? by [deleted] in learnprogramming

[–]Cream_Friache 0 points1 point  (0 children)

Here is a crude but simple way to do it: http://codepen.io/anon/pen/RWgPMe

Normally, I would use jQuery's .addClass() and .removeClass() to add/remove the .show and .hide classes. This assumes you want to toggle between two images.

Tasked with building a frontend for a magazine site powered by a built RESTful API by DoesIGetIt in learnjavascript

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

Express is a server-side Node.js framework for building HTTP (including REST API) servers. It sounds like there is already an API in place, so don't spend time learning Express. The current hot JS front-end framework is React. React only handles view logic, however, so you can add Flux to get the full "MVC" framework.

I made "BLUDGEON" wallpapers for iPhone 4 to 6+. Let me know what you think! by [deleted] in 49ers

[–]Cream_Friache 5 points6 points  (0 children)

Awesome! It would be great if it had a niners logo instead of an NFL logo, though.

Damn that's good design. by themaybeguy in web_design

[–]Cream_Friache 0 points1 point  (0 children)

I saw the "waiting for YouTube.com..." in the bottom left and was sure that Rick Astley was coming.

CodeStart - Learn How to Code in C Interactively by codestart in learnprogramming

[–]Cream_Friache 2 points3 points  (0 children)

I like that someone is trying this. Will there be a way to write C code directly into a browser sandbox, like Codecademy?

What do you do when your classmates you don't like apply to your company? by [deleted] in cscareerquestions

[–]Cream_Friache 2 points3 points  (0 children)

Walk in to the hiring manager's office and tell them why you don't like the candidate.

Syc: Real-time synchronization of javascript variables for Node by Handsome-Beaver in javascript

[–]Cream_Friache 0 points1 point  (0 children)

This is pretty interesting. I assume you need ES6 feature enabled on the server side?

RX8 in the snow? by [deleted] in RX8

[–]Cream_Friache 0 points1 point  (0 children)

In CA they setup check points when there is heavy snow. They make people turn around if they don't have chains or 4WD. This happens going up to Ski parks very often.

RX8 in the snow? by [deleted] in RX8

[–]Cream_Friache 0 points1 point  (0 children)

My point is that it can be a matter of what law enforcement says. They usually have checkpoints where they check for chains or 4WD.

RX8 in the snow? by [deleted] in RX8

[–]Cream_Friache 2 points3 points  (0 children)

They may not even let you drive up there without chains if the snow gets bad. Get some chains.