ES6 Fundamentals : Classes

Points that confused me initially, thinking classes in ES6 doesn’t require much reading as I already have a background of C# and Java.

  1. No members can be defined directly in a class
    Unlike other languages like C# or Java, we can not define class members directly in ES6. Whichever member a class requires it needs to be defined in constructor itself or inside methods of the class associated with ‘this’ object.
  2. No method can be called from another method in same class without associating it with ‘this’ object.
    If we define a method a(), and call it inside b() like b() { a(); } it will give an error specifying a is not defined. However, if we define b() like b() { this.a(); } it will work. So, every method in a class must be associated with this object to call inside another method in same class.
  3. Using private members across methods requires additional efforts
    In ES6 classes, we cannot simply define a variable and use it across all the methods in that class. That doesn’t mean we cannot do that, but that’s a tricky part and  requires writing additional bit of code.
  4. super() is essential to extend a class

Advertisements

SHORT, SIMPLE and BASIC

Host Objects vs Native Objects:

Host objects are defined as objects that are environment specific and supported only by environment in which program executes. For example, DOM Objects (window, document, XMLHttpRequest )which are not part of ECMAScript specification but are environment specific, i.e. supported by browsers only.

Native objects are those objects which are define in specification. For example, Object, Array, Date, Math etc.

Make your information more beautiful with Google Web Fonts

Appropriate typography is very important for our websites to be more presentable. So, its an important matter of consideration for web designers while choosing which font family they are going to use
for their websites.

While choosing fonts for our website, we definitely focus on two points :

  1. Choosing fonts that most people have on their computers. And that’s why the world of information in web revolves around Arial, Verdana & Georgia, a world with simplicity.
  2. Specifying a list of even-more-common alternate fonts to be used when your preferred font isn’t installed .

And, that leaves limited options for designers, either to use an image in place of text or to choose a font which is very much common. So, open source web fonts came into picture as a rescue to the web designers.

Google fonts API :
Entering into the web typography world, Google debuted its custom font service under the Google Font API, with a varied collection of high quality open source fonts for the Google Font Directory. And there started a life beyond Verdana.

“The Google Font API provides a simple, cross-browser method for using any font in the Google Font Directory on your web page. The fonts have all the advantages of normal text: in addition to being richer visually, text styled in web fonts is still searchable, scales crisply when zoomed, and is accessible to users using screen readers.” – Says Google Font API team.

How to use Google Font API :
Pretty simple. Just add a couple lines of HTML:
Add a stylesheet link to request the desired web font(s):
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Font+Name">
Style an element with the requested web font, either in a stylesheet:
CSS selector {
font-family: ‘Font Name’, serif;
}
or with an inline style on the element itself:

Your text

Points to keep in mind :

When specifying a web font in a CSS style, always list at least one fallback web-safe font in order to avoid unexpected behaviors. In particular, add a CSS generic font name like serif or sans-serif to the end of the list, so the browser can fall back to its default fonts if need be.” – Says Google as Precautionary Note. Why?

Let me think of the worst, Google itself goes offline (No doubt it may happen someday). Or, if the visitors for the content are not limited to Western Countries only.

Second, downloading a font slows down the loading of your page. When you select a font from Google Web Fonts, you’ll see a graphic indicating the impact that your font choice will have on your page’s load time.

Third, most browsers load the rest of the page before loading the fonts we apply from Google fonts collection. This produces a lag which need to be covered with appropriate web-safe font, which is definitely not a perfect alternate.

Conclusion
As a conclusion, we may say that Google Fonts are pretty cool to use but needs some precautions. And, if used wisely, taking care of all the measures, it may produce good results.

Hello world!

Welcome to WordPress.com. After you read this, you should delete and write your own post, with a new title above. Or hit Add New on the left (of the admin dashboard) to start a fresh post.

Here are some suggestions for your first post.

  1. You can find new ideas for what to blog about by reading the Daily Post.
  2. Add PressThis to your browser. It creates a new blog post for you about any interesting  page you read on the web.
  3. Make some changes to this page, and then hit preview on the right. You can always preview any post or edit it before you share it to the world.