Skip to main content

Introduction To JavaScript

JavaScript Language has following characteristics:
  • Lightweight: Small memory footprint, easy to implement
  • Interpreted: No compilation, Instructions executed only
  • Object Oriented: Modeled around objects
  • First-class functions: Functions used as variables and parameters
  • Scripting language: Writing instructions for runtime environment
JavaScript is used for 
  • Client side web development
    • Frameworks: JQuery, AngularJs, React, EServer-side
  • Server-side web development
    • Frameworks: NodeJS, Express
Variable declaration and definition
  • Declaration: Give a name to a variable
  • Definition: Assign a value to the variable
Equal operations 
  • =: assigning value to a variable (a=30)
  • ==: check the values (doesn't consider types)
  • ===: check the values and types
Functions: 
  • no overloading
  • functions are objects
  • functional expression : assign function to variable
  • anonymous function: function with no name
Array methods
  • push(value): value is appended to the last position of an array
  • pop(): last element is removed
  • shift():first element is removed
  • unshift(value): values is appended as first element

Other Points 

  • Native JavaScript: Doesn't use any framework 
  • Doesn't associate type with variables
  • If you declare a variable and not define yet: it has undefined value
  • type of null in Javascript: object
  • For all non-zero values variable return as true.
  • JavaScript is not a class-based language: can add properties to object dynamically
  • Arrays behave like an object
  • Arguments: keyword that gets function arguments as list






Comments

Popular posts from this blog

Object Oriented Programming (OOP)

Object Object is an entity that has state and behavior Class Collection of objects is known as class. There are four main types of OOP concepts Inheritance Object acquire all the properties and behavior of parent object Improve code re-usability Polymorphism One task is performed by different ways Use method overload and override Abstraction Hiding internal details and showing functionality Use abstract class and interfaces Encapsulation Binding code and data into a single unit

Sorting Algorithms

Bubble Sort Named as sinking sort. Compare each pair of the adjacent items and swap them if they are in the wrong order. Worst case and average case time complexity both O(n^2)  and best case time complexity is O(n).

Java-8

Java 8 New Features There are several new features added in Java 8 version. Some of the important new features are: Define methods inside the interface For each method Lambda Expression Stream API DateTime API 1) Define methods (default, static) inside the Interface After you published your interface, you can't change it by adding some abstract methods. But if you want to add methods you can define those methods inside the interface. Therefore Java 8 support default and static methods inside the interface. In Java 7 version interface only have abstract methods (no method implementation) and an abstract class can have both abstract and non-abstract methods. In Java 8 version you can add method implementation in the interface, but you have to declare that method as default method. ex: default void show(){............} To avoid diamond problem you have to override the method in implementation class if two interfaces have same default method ...