Jquery taught by codeacademy


#1

Why is the jquery taught at codecademy different from other sources on the internet?
for example, the anonymous function declaration is different and declaring jquery objects.


#2

We need some context, here. Please post the URL of the lesson you are on, as well as your own code.


#3

This is how anonymous functions are declared in the jquery exercise on codecademy.
$(document).ready(() => {
});

This is how anonymous functions are declared elsewhere
$(document).ready(function() {
});

Can you please explain why is it like that?


#4

Would appreciate that link, please.

Both forms are valid. The arrow function syntax was introduced in ES6 and behaves like any function with a couple of exceptions…

  1. no this object
  2. no arguments object

JavaScript Arrow Functions

If you use an arrow function inside another function, it accesses that function’s this object, and that function’s arguments object.


#5

Hi,

Thanks for the explanation.
I have watched a few videos to learn jquery and people did not use the arrow function which is why I got confused.

Here is the link to the codecademy lesson:
https://www.codecademy.com/courses/learn-jquery-introduction/lessons/jquery-setup/exercises/review?action=resume_content_item&course_redirect=learn-jquery

Thanks!