Showing posts with label Basic Javascript. Show all posts
Showing posts with label Basic Javascript. Show all posts

Monday, December 30, 2019

What are the new features introduced in Angular 5?


Angular 5 came with a lot of new features which help and attract developer at any point of time on Angular specific task. It also has some earlier bug fixing which also helps angular developer for smooth coding.

AOT feature is making as a default feature.
  • 1.       Activating watching mode which helps developer especially in debug.
  • 2.       Introducing type checking utility for the template.
  • 3.       Metadata saving and fetching utility making more advance which makes it more flexible.
  • 4.       Unwanted ts file like *.ngfactory.ts has been removed permanently.
  • 5.       Displaying error message are more meaningful which help angular developer on error investigation.
  • 6.       Feature upgrades are more smooth then earlier.
  • 7.       Introducing new Tree shakeable components help angular developer for a new feature.
  • 8.       More advance in case of Hybrid upgrade application.
  • 9.       Improve their performance more than earlier versions.


What are the key components of Angular?
Angular has the below key components,
  • 1.       Component: These are the basic building blocks of angular application to control HTML views.
  • 2.       Modules: An angular module is set of angular basic building blocks like component, directives, services etc. An application is divided into logical pieces and each piece of code is called as "module" which perform a single task.
  • 3.       Templates: This represent the views of an Angular application.
  • 4.       Services: It is used to create components which can be shared across the entire application.
  • 5.       Metadata: This can be used to add more data to an Angular class.


Tuesday, June 30, 2015

What is the main difference between window.onload and onDocumentReady?

Both functions are used to perform tasks when the page is loaded in the browser but they have important differences. Most importantly, "window.onload" will execute code when browser has loaded the DOM tree and all other resources like images, objects, etc, while onDocumentReady allows you to execute code when only the DOM tree has been built, without waiting for images to load. Thus, you can start scripting agains the DOM much quicker with onDocumentReady. Another important difference is that window.onload is not cross-browser compatible while using something like jQuery's document.ready() will work nicely on all browsers.

Monday, June 29, 2015

decodeURI(), encodeURI()



Many characters cannot be sent in a URL, but must be converted to their hex encoding. These functions are used to convert an entire URI (a superset of URL) to and from a format that can be sent via a URI.
<script type="text/javascript">
var uri = "http://www.google.com/search?q=sonofusion Taleyarkhan"
document.write("Original uri: "+uri);
document.write("<br />encoded: "+encodeURI(uri));
</script>

What's Prototypes for JavaScript?



Objects have "prototypes" from which they may inherit fields and functions.
<script type="text/javascript">
function movieToString() {
return("title: "+this.title+" director: "+this.director);
}
function movie(title, director) {
this.title = title;
this.director = director || "unknown"; //if null assign to "unknown"
this.toString = movieToString; //assign function to this method pointer
}
movie.prototype.isComedy = false; //add a field to the movie's prototype
var officeSpace = new movie("OfficeSpace");
var narnia = new movie("Narni","Andrew Adamson");
document.write(narnia.toString());
document.write("
Narnia a comedy? "+narnia.isComedy);
officeSpace.isComedy = true; //override the default just for this object
document.write("
Office Space a comedy? "+officeSpace.isComedy);
</script>

eval()?



The eval() method is incredibly powerful allowing you to execute snippets of code during execution.
<script type="text/javascript">
var USA_Texas_Austin = "521,289";
document.write("Population is "+eval("USA_"+"Texas_"+"Austin"));
</script>
This produces
Population is 521,289

How to create a function using function constructor?



The following example illustrates this
It creates a function called square with argument x and returns x multiplied by itself.
var square = new Function ("x","return x*x");

What does break and continue statements do?


Continue statement continues the current loop (if label not specified) in a new iteration whereas break statement exits the current loop

What is restrict option in directive?

The restrict option in angular directive, is used to specify how a directive will be invoked in your angular app i.e. as an attribute, class...