Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

General JavaScript

Featured Replies

Some great replies on Quora regarding whether or not to use jQuery in your projects. I 100% agree with the first response. http://www.quora.com/Should-a-JS-focused-start-up-use-jQuery

 

There's also the additional time to factor in that it takes to write everything (and test cross-browser) things you've written in vanilla js. If you're worried about speed then there's other areas of a project that a far easier to optimise (images hint ;) You can always do what I do - I use vanilla js for the initial content in the page, my navigation etc, and jquery gets deffered so the effect being that jQuery makes no perceived difference to the page load.

 

The only time I'd roll completely without jQuery is if I was doing very little DOM manipulation and no Ajax otherwise my time is better spent elsewhere.

 

Also of note - it's probably better to spend time learning the actual language in great detail inc ES6 than learning the native DOM APIs. I'm not saying you shouldn't learn them but I think it's best to prioritize learning - the what you need to know stuff :)

  • Replies 422
  • Views 70.5k
  • Created
  • Last Reply

Top Posters In This Topic

Most Popular Posts

  • As soon as I saw the JS videos with that Mattias guy, I knew who he was straight away. He posts some really useful answers on Quora. I'd advise signing up if you haven't already. I've wasted hours re

  • Console.table, ladies and gentleman http://jsfiddle.net/juu5fx82/.   You need to use the JS console obviously, and hit 'run'. I never knew this existed.

  • jQuery's modular, you can build a custom version via Grunt, its pretty simple.   Before v3.0, which now uses requestAnimationFrame and Promises/A+, I'd use a build without Effects and Ajax with Velo

Thank you! Will play with rule2 and handlers today.

Working with addEventListener with and without arguments! :) Great article!

there's loads of functions attached to the console object, just hit console in the console and look up the prototype chain, here's a list of all the methods, have no idea what some of them do but it might be worth playing around with :)

  1. assert: assert()
  2. clear: clear()
  3. constructor: ConsoleBase()
  4. count: count()
  5. debug: debug()
  6. dir: dir()
  7. dirxml: dirxml()
  8. error: error()
  9. group: group()
  10. groupCollapsed: groupCollapsed()
  11. groupEnd: groupEnd()
  12. info: info()
  13. log: log()
  14. markTimeline: markTimeline()
  15. profile: profile()
  16. profileEnd: profileEnd()
  17. table: table()
  18. time: time()
  19. timeEnd: timeEnd()
  20. timeStamp: timeStamp()
  21. timeline: timeline()
  22. timelineEnd: timelineEnd()
  23. trace: trace()
  24. warn: warn()

Kyle must go into a lot of detail in the Coercion course, I didn't realise you could even do a whole course in that! I am assuming the basics course is now what should be done before people tackle his advanced Javascript course..?

 

Would be nice if frontend masters created some kind of path(s) to follow like Treehouse have a front-end path.

  • Author

Kyle must go into a lot of detail in the Coercion course, I didn't realise you could even do a whole course in that! I am assuming the basics course is now what should be done before people tackle his advanced Javascript course..?

 

Would be nice if frontend masters created some kind of path(s) to follow like Treehouse have a front-end path.

 

There's another course coming from Kyle, it could be online this week.

 

I'd say Bianca's course is a good next one. Then maybe Advanced JS Fundamentals to jQuery & Pure DOM Scripting, then Kyle's advanced JS?I haven't done the last two. I agree though, a roadmap would be really helpful. I sent a message to Marc last week, saying they should put the videos into categories, and have a difficulty rating.

Programming javascript application by Eric Elliot is really fun. But he use jQuery a lot in his book. It's not good, but in whole - awesome. Eric is really has a great skills in practice. Add to that he is a very good teacher and has ability to explain complicated things by simple words and examples. Awesome book! I was confused in many things before start reading this book.

Edited by fleur

Tell me - What is wrong with jQuery?

 

Nothing wrong. I like jQuery. But with vanilla js knowledge i can fit in project in any framework (company mostly used backbone.js). I like make UI on jQuery, but GSAP seems to be more powerful for working with UI. On treehouse i see that memebers asked about solution in vanilla js, although blog has good course with ajax and jQuery. Times changed and i like it:) When i go deeper inside js i see how awesome it is, vanilla i mean.

But there's nothing wrong with using jQuery in producing Apps, so Eric Elliots use of jQuery in his book is actually a good thing.

It's good to learn the original DOM API, but remember that isn't JavaScript, it's an API - and a very poor one at that. jQuery abstracts this into something much more readable and normalizes the browser differences. This is especially true with Ajax, writing cross browser Ajax without jQuery or a similar library is not fun.

And don't forget that jQuery is JavaScript.

 

If you are short on time to learn it's better to learn JavaScript (The language not the DOM API) and then jQuery, and you will be highly productive. The problem is a lot of devlopers know jQuery but don't actually understand the language, not knowing the DOM API isn't as much of a problem as it can be abstracted.

Edited by rbrtsmith

Agree this you on 1000! And MDN tells the same. But DOM is important for many things and i practise DOM now for creating dynamic elements. I can practise js all my life and no one can know js on 100%, even Eric and Kyle:) If i can believe treehouse - ajax have big problem mostly with IE9 and below. But it's okey and i don't make sites for IE8. IE8 is windows XP. It's outdated. I start learn jq before js and now i see that i was wrong. Because if you know vanilla js although on 50% js frameworks is easy to learn. Agree with you again.:)

https://frontendmasters.com/courses/organizing-javascript/ looks very very good! I didn't see the course about functional programming, will search the link, i think it's better to take the last one before.

 

"No amount of learning the theory of JavaScript will substitute for actually practicing the implementation of it."

Great words! I start believe in Kyle:)

 

"server.js Walkthrough Kyle starts up the stripped-down version of his secure phrase generator that he’ll be working form. He walks through Node’s server.js file to explain how the application is organized."

 

it means that for that course i need to have Node.js knowledge, right?

Edited by fleur

  • Author

https://frontendmasters.com/courses/organizing-javascript/ looks very very good! I didn't see the course about functional programming, will search the link, i think it's better to take the last one before.

 

"No amount of learning the theory of JavaScript will substitute for actually practicing the implementation of it."

Great words! I start believe in Kyle:)

 

"server.js Walkthrough Kyle starts up the stripped-down version of his secure phrase generator that he’ll be working form. He walks through Node’s server.js file to explain how the application is organized."

 

it means that for that course i need to have Node.js knowledge, right?

 

The 'Hardcore Functional Programming' course is extremely difficult. I got about 45 seconds into it. Bianca does a course on objects, functions, scope, functional programming, and underscore JS, which is awesome. I'd suggest watching that one first.

 

I watched the first part of the Coercion course last night, even though for the most part I understand how it works. There's some really interesting stuff that Kyle talks about in between. Like how the TC39 committee works, how features are implemented, why bugs aren't fixed. It's well worth watching. I'm going to watch part 2 tonight.

 

It's interesting how Kyle uses the == rather than the often recommended ===. It will be nice to see a valid reason why at some point in the course.

Thank you a a lot for advice! Coercion is another course? i didn't understand. Agree that "Functional Programming" should goes first. I saw that "organizing javascript functionality" has, for example this point:

03:51:55 - 04:01:53 Streams

It means that it takes only one minutes? It's very small if so..

 

Also i didn't get if this link is full version of Eric book or just overview of every chapter ?

 

there is good collection of js books (include by Eric, Nikolaz and others)

Edited by fleur

  • Author

Thank you a a lot for advice! Coercion is another course? i didn't understand. Agree that "Functional Programming" should goes first. I saw that "organizing javascript functionality" has, for example this point:

03:51:55 - 04:01:53 Streams

It means that it takes only one minutes? It's very small if so..

 

Also i didn't get if this link is full version of Eric book or just overview of every chapter ?

 

Coercion is a new course. There are two others, a JS basics one and an organising JS one. Kyle Simpsons teaches all three. I have a feeling that Kyle will eventually teach the entirety of the You Don't Know JS series, but that's just a guess for now.

 

There are a few courses that cover functional programming on there, but they vary in difficulty. The 'Hardcore Functional Programming' is difficult. If you're interested in learning more first, there's a course called 'JavaScript: From Fundamentals to Functional JS' which covers objects, scope, functions, closure and functional programming basics. I'd start there. It's a great course, taught by Bianca, from the infamous Hack Reactor school in San Francisco.

I'd say the hardcore functional programming course is primarilly aimed at senior js engineers looking to further level up. After watching the first 15 mins I can say it goes well over my head. Like Jack put do Biancas course. Its a good intro to the concepts.

Dont try and focus too much on advanced concepts at this stage, you'll only confuse yourself.

I recommend you watch anything by Kyle Simpson @@citypaul, and his book series they're all very, very good. He has quite a few videos on FEM, not sure about Pluralsight but if it's there his advanced JS course is a must!

 

I would say difficulty is intermediate too, not advanced. Hardcore functional programming though, that is advanced, to say the least.

Edited by rbrtsmith

 

His Advanced course is on there. I read his book on scope and closures and have the one on the "this" keyword but haven't read it yet. I'm planning on going through his advanced series on Pluralsight, and from there probably taking a look at his real time with nodejs series. I'm particularly interested in the webrtc stuff.

 

Just for the record, he has the same thoughts with regard to classes as Eric Elliot, I read his book on this & prototypes on my flight and he said pretty much the same - although to be fair it was more targeted as people trying to use JS in a classical kind of manner, rather than classes in other languages.

Anyway it's a good read, I've been going through his Async & performance book today, need to properly wrap my head around promises.

Edited by rbrtsmith

You might be right, I've never used classes so I cannot argue either way, but I know (a growing) list of some of the most senior devs who say functional programming is more robust and a better option on large scale systems than classes.

 

Food for thought - this short twitter convo with me, @@Lyndsey and a senior dev at Spotify on the topic: https://twitter.com/mpjme/status/634492132615712768

 

The more I learn about JS the more I like it actually, it has it's issues, but functional programming is really growing on me, and although JS isn't the only language that can be written in this way, it was the one that brought it into the mainstream. I do really like prototyping it's just objects linking to other objects, not copies but proper delegation, and the fact you can create an object literal out of thin air with no class is a wonderful feature of the language.

 

But of course I am biased - I've been influenced heavily by CrockFord and Kyle Simpsons writings.

Edited by rbrtsmith

Interesting. :) On Quora i saw the very interesting article, where one guy was fired from work after the diploma as a programmer. He knows a lot how to program (javascript etc) ...on abstract examples. But when he join to the real project he couldn't do nothing for 2 month. After this story i start understand that there is a big problem. And i don't want to spend a years, only reading and looking great names for theory. For that reason i learned the base of js, after that contacted with companies, explained the problem that i need the practice and asked to send me tests on front-end position. HR was very kind and 90% of companies sent me the tests. And now i understand all theory and all "dark places" that i had before :) Easy:)

  • 2 weeks later...

A really decent offer on Frontend Masters. Looks like some great content coming up too.

 

https://frontendmasters.com/sale/

 

A great deal that! Like the look of the in depth look at Netflix.

 

Less enthusiastic about TDD using CoffeeScript, why not just TDD in JavaScript itself? - i see little point in learning Coffee now with ES6 now a standard. Sadly FEM is lacking in TDD courses as all are in some kind of framework like Angular. Hopefully they will fix this.

That's a minor niggle though because it's a fantastic resource, certainly the best one I know of to cover intermediate to advanced concepts.

 

Meteor course sounds good, heard great things about Meteor.

  • Author

 

A great deal that! Like the look of the in depth look at Netflix.

 

Less enthusiastic about TDD using CoffeeScript, why not just TDD in JavaScript itself? - i see little point in learning Coffee now with ES6 now a standard. Sadly FEM is lacking in TDD courses as all are in some kind of framework like Angular. Hopefully they will fix this.

That's a minor niggle though because it's a fantastic resource, certainly the best one I know of to cover intermediate to advanced concepts.

 

Meteor course sounds good, heard great things about Meteor.

 

Meteor looks amazing.

 

I agree, my impressions were the same initially, but I think the TDD stuff is more of a methodology than syntax, so hopefully it will be easy to put into practice and write it in vanilla JS. I remember Citypaul saying that the TDD screencasts he watched were on Java, or something, but the ideas are transferrable to other languages, because it's more about the concept.

 

Meteor looks amazing.

 

I agree, my impressions were the same initially, but I think the TDD stuff is more of a methodology than syntax, so hopefully it will be easy to put into practice and write it in vanilla JS. I remember Citypaul saying that the TDD screencasts he watched were on Java, or something, but the ideas are transferrable to other languages, because it's more about the concept.

 

I have gone through this, which is a testing framework that can be used with Vanilla JS http://build-podcast.com/mocha/ I was just hoping FEM could do something more involved like a full project workflow incl TDD

Interesting responses from Mattias Johansson on a recent Quora thread: Why should we force JS to use a class mechanism and class keywords?

 

After following and studying from the likes of Crockford, Kyle Simpson, Eric Elliot who all teach that classes are an antipattern in JS - and programming as a whole according to Crockford. I've also recently been following Mattias P Johansson who's a senior engineer at Spotify so knows a thing or two at programming in large systems... I thought I'd post this to sort of add a little more fuel to the fire.

 

Question::

I beleive javascript has its own beauty. It has its own style of handling stuff, so thats why it wants developers to think in terms of approach which is not very common among other programming languages. The question is why community want to force it to add class keywords and other stuff to make it behave like other programming languages like C/C++, Java etc.

 

Mattias response

I know where you are coming from, but I view it this way: If people want to do drugs, at least give them clean needles.

Inheritance is (almost always) a bad pattern and you should use composition instead (read the book http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612/ref=sr_1_1?ie=UTF8&qid=1441049218&sr=8-1&keywords=design+patterns if you are interested in why). Classes are dubious because they encourage inheritance because they make inheritance very easy and composition hard. Even so, classes got very popular along the way, and now it is what people are used to. So much, that they try to shoe-horn them into JavaScript even though it's fits badly, making messes. But, if people absolutely must use them, then it's acceptable that we provide a clean way of doing it.

 

Comment Reply to Mattias

I think claiming that inheritance is "almost always" a bad pattern is a bit of a stretch.
I have a lot of respect for your opinions but I feel that statements like this are simply not helpful.
Can inheritance be misused? Sure. But the same is true of most programming language features.
Also, I think you have to agree that "Classes are dubious because they encourage inheritance because they make inheritance very easy and composition hard" is a bit of a non-starter.

 

Composition is not mutually exclusive to inheritance and never has been. Both have their uses and neither is always the right answer.
Mattias reply to comment
Just to be clear on my intentions here. I currently feel like inheritance is incredibly common and composition is very rarely used. I think that is completely topsy-turvy and feel like the relationship should be inverse. I feel like inheritance is like mutable state - something that should be used pretty rarely, but in practice is used all over the frickin' place.
"Can inheritance be misused? Sure. But the same is true of most programming language features."
Yes, but almost no feature is so WIDELY misused and overused. It so oversold that we need to make clear that there is an alternative. I see senior developers all around me use singletons inheriting each other for absolutely no reason, just because "always use classes" is such a widespread dogma.
"Also, I think you have to agree that "Classes are dubious because they encourage inheritance because they make inheritance very easy and composition hard" is a bit of a non-starter."
No, I don't agree. That statement is correct. At least when it comes to ES6 classes. There is a built in-function in them to inherit them, but none to compose them. That certainly encourages it.
"Composition is not mutually exclusive to inheritance and never has been. Both have their uses and neither is always the right answer."
I agree with this. I also never claimed otherwise.
  • Author

This demonstrates the power of Meteor, a true isomorphic framework that runs on the client, server, and native OS. Using the same code on everything.

https://hansoftx.com/blog/building-an-ultra-responsive-ui

In a different blog post, they said they built an "ultra responsive and snappy mobile app sharing 98% code with web". Pretty impressive.

This demonstrates the power of Meteor, a true isomorphic framework that runs on the client, server, and native OS. Using the same code on everything.

 

https://hansoftx.com/blog/building-an-ultra-responsive-ui

 

In a different blog post, they said they built an "ultra responsive and snappy mobile app sharing 98% code with web". Pretty impressive.

 

Yes Meteor looks great. It's possible to do isomorphic - or more recently labelled universal JavaScript in whatever flavour of JS you prefer using tools like WebPack and Browserify to bundle up node-js based modules for the browser enviroment - it's very common with Node powered React apps to do this.

 

Meteor supposedly allows you to rapidly prototype such 'universal' apps

  • Author

 

Yes Meteor looks great. It's possible to do isomorphic - or more recently labelled universal JavaScript in whatever flavour of JS you prefer using tools like WebPack and Browserify to bundle up node-js based modules for the browser enviroment - it's very common with Node powered React apps to do this.

 

Meteor supposedly allows you to rapidly prototype such 'universal' apps

 

Meteor pairs well with React and Angular, but also appears to save a lot of the hard work server side. I guess it's an alternative to rolling your own in Node, which looks like a lot of work in some cases.

 

http://info.meteor.com/blog/meteor-the-missing-infrastructure-for-building-great-react-apps

 

Meteor pairs well with React and Angular, but also appears to save a lot of the hard work server side. I guess it's an alternative to rolling your own in Node, which looks like a lot of work in some cases.

 

http://info.meteor.com/blog/meteor-the-missing-infrastructure-for-building-great-react-apps

 

I've not really played with meteor so it's hard to compare, but express is a very nice framework to build out web projects in Node. I've only ever used node for educational purposes, so far always rolled with express. CodeSchool do a great course in express if you haven't already do it :)

 

Mattias advised me to check out Meteor to have my mind blown.. so I'll have to take that advice at some point - a nother thing to add on my big list of stuff to learn.

  • Author

Mattias advised me to check out Meteor to have my mind blown.. so I'll have to take that advice at some point - a nother thing to add on my big list of stuff to learn.

 

There always seems to be something really cool that I hear about built on Meteor.

 

I sent a Tweet to the company featured in that blog, and asked what the process was for updating the native app. Usually you have to re-submit the app to the app store, but some of the JS solutions make it easier, in some cases you don't have to. They said:

 

"It is automatic, when Meteor updates it does a hot code push and all clients refresh". That's pretty insane.

 

There always seems to be something really cool that I hear about built on Meteor.

 

I sent a Tweet to the company featured in that blog, and asked what the process was for updating the native app. Usually you have to re-submit the app to the app store, but some of the JS solutions make it easier, in some cases you don't have to. They said:

 

"It is automatic, when Meteor updates it does a hot code push and all clients refresh". That's pretty insane.

 

That is a nice feature. i'm sure it's very different to React, and could possibly coincide. It's hard to take my attention from React right now, a lot of the ideas in React seem to be the way the industry is headed - components, virtual DOM and flux. My understanding of all this is limited but look what Mattias had to say here:

http://www.quora.com/Which-should-I-choose-for-a-new-web-application-AngularJS-or-Flux-React-and-why

 

He doesn't mention meteor, but I'm trying to be very careful of what I spend my time learning, I don't wanna spend it learning something that will soon be obsolete - time such a precious commodity. What kind of future does meteor have?

  • Author

That is a nice feature. i'm sure it's very different to React, and could possibly coincide. It's hard to take my attention from React right now, a lot of the ideas in React seem to be the way the industry is headed - components, virtual DOM and flux. My understanding of all this is limited but look what Mattias had to say here:

http://www.quora.com/Which-should-I-choose-for-a-new-web-application-AngularJS-or-Flux-React-and-why

 

He doesn't mention meteor, but I'm trying to be very careful of what I spend my time learning, I don't wanna spend it learning something that will soon be obsolete - time such a precious commodity. What kind of future does meteor have?

 

The future looks bright for the product. It has a massive community.

 

I'd say learn React, because you can use it happily with Meteor. Meteor is great for handling databases, security, and server-side stuff. You could build some really cool products with it without having to roll your own with Node, Handlebars ect, which is much more time consuming for side-projects or hackathon stuff.

 

Have a read through this tutorial when you have time http://meteortips.com/first-meteor-tutorial/, it should take an hour or so to get through the book, but it shows how powerful the framework is, you barely have to write anything and it's incredibly clear what the code is doing.

I have a quick* question and I suposse it is ok to post it in this thread rather than start a new topic.

 

I'm working on a JS application and at page load a function is called which loops through a group of elements and bind click events to them.

The user can create new elements of the same kind and to bind events to the new elements I'm thinking I can:

 

A. Call the function (with the loop) again This will result in the same eventlistener would be added to the "old" elements again. Is that a problem?

 

B. Alternatively I could remove the eventlisteners first when the function is called but the "new" elements wouldn't have an event attached at that point so for these I'll be removing an event that does not exist. Is that a problem?

 

C. As I understand there is no method that will return if an element has an event attached so I can not use a conditional statement unless I add a custom property to each element when it is created. The value of this property would have to change after the event is attached. It's no problem but I'm hoping it is not necessary and that I can settle for option A or B.

 

What do you think?

 

 

* Ok, In my mind it was a "quick question"

Edited by Nillervision

I have a quick* question and I suposse it is ok to post it in this thread rather than start a new topic.

 

I'm working on a JS application and at page load a function is called which loops through a group of elements and bind click events to them.

The user can create new elements of the same kind and to bind events to the new elements I'm thinking I can:

 

A. Call the function (with the loop) again This will result in the same eventlistener would be added to the "old" elements again. Is that a problem?

 

B. Alternatively I could remove the eventlisteners first when the function is called but the "new" elements wouldn't have an event attached at that point so for these I'll be removing an event that does not exist. Is that a problem?

 

C. As I understand there is no method that will return if an element has an event attached so I can not use a conditional statement unless I add a custom property to each element when it is created. The value of this property would have to change after the event is attached. It's no problem but I'm hoping it is not necessary and that I can settle for option A or B.

 

What do you think?

 

 

* Ok, In my mind it was a "quick question"

 

I would use event delegation for this. As we all know, an event in JavaScript bubbles up the DOM, so when you click on an element, say a <li>, that event bubbles all the way up to the parent <ul> element and all the way up to the root element.

 

So by assigning the click event to the parent element, in this case the <ul>, we can use event.target to determine if the <li> was clicked.

 

Because we're assigning the event to the parent element, it doesn't matter if the list elements are there by default or if they're added dynamically. The delegation should take care of it.

 

This method is great for what you're needing to do, and means you don't have to re-assign event handlers etc. It only needs to be assigned once.

 

Here are some examples:

 

http://davidwalsh.name/event-delegate

http://code.tutsplus.com/tutorials/quick-tip-javascript-event-delegation-in-4-minutes--net-8961

 

Edit: I created a simple example https://jsfiddle.net/LyndseyB/6ogdr32p/

Edited by Lyndsey

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.