Skip to main content

Posts

Showing posts from July, 2017

Javascript ECMAScript6 New Feature

Arrow functions  I think that an  arrow functions  are one of the best features of  ECMAScript 6 , excluding  class -es and  OOP  programming at all. It has really very helpful and  useful syntax  for scripting language. So let’s check it out: Syntax     //Function with no parameters:     () => { statements } ]     //Function with single parameter:     singleParam => { statements }     //Function with one and more parameter:     (param1, param2, …, paramN) => { statements }         //Function with simple return statement:     n => n * 2 How did it look in ECMASript 5?     //Function with no parameters:     function () { statements }     //Function with single parameter:     function ( singleParam ) { return statements }     //Function with one and more parameter:     function (param1, param2, …, paramN) { return statements }         //Function with simple return statement:     function (n

Javascript ECMAScript6 New Feature

ECMAScript 6 Const Const In  ECMAScript 6  we have  const  variable arrived. Does it work the same as C++  const ? Not exactly. I would even say,  “not at all” . When you declare something with  const  in  ECMAScript 6 , it means that the  identifier can’t be reassigned.   What does it mean?   It means that you cannot declare that variable more than once. Because its  binding is immutable .  You have guaranty that  no rebinding will happen  to it.  You will  not  be able to change its  type . If your  const  variable is a simple value, like  string ,  number ,  boolean  etc. you also  wouldn’t be able to change its value . So let’s look how does it work: Declaration Very simple. Just use  const  instead of  var  :     const brandColor = 'turquoise' ;   The value of a constant doesn’t have to to be known at compile time, but you must assign it a value exactly once. Const  and scopes Redeclaring: Constants can’t be redeclare

Angular 2 - Architecture

Angular is designed to be modular, an Angular 2 app comprises of several  components , which are connected via routing or selectors, these components may have templates attached to it which may display component prope rties and attach events to interact with the properties Modules Angular App comprises of several  Modules , a module typically exports something of a purpose. A module is a set of similar utilities that perform a similar task. Typically a module may export a class which we may be imported in other modules. Angular 2 itself ships in large modules, some of them are ‘ angular/core ‘, ‘ angular/router ‘ and there are more. Components Components are the  basic building blocks  of an Angular 2 app. A component is typically a type-script class which has a template attached, it usually assembles a screen, ui-element or a route in the application. A component may have child components.  A component has a metadata/ decorator associated which describes the component. M