diff --git a/GoodLearning b/GoodLearning new file mode 100644 index 0000000..1607908 --- /dev/null +++ b/GoodLearning @@ -0,0 +1 @@ +Thanks to seniors for teaching JS diff --git a/uses.txt b/uses.txt new file mode 100644 index 0000000..d115904 --- /dev/null +++ b/uses.txt @@ -0,0 +1,17 @@ +Class declarations +One way to define a class is using a class declaration. To declare a class, you use the class keyword with the name of the class ("Rectangle" here). + +class Rectangle { + constructor(height, width) { + this.height = height; + this.width = width; + } +} +Hoisting +An important difference between function declarations and class declarations is that function declarations are hoisted and class declarations are not. You first need to declare your class and then access it, otherwise code like the following will throw a ReferenceError: + +const p = new Rectangle(); // ReferenceError + +class Rectangle {} +Class expressions +A class expression is another way to define a class. Class expressions can be named or unnamed. The name given to a named class expression is local to the class's body. (it can be retrieved through the class's (not an instance's) name property, though).