This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="../core-scaffold/core-scaffold.html" rel="import"> | |
<link href="../core-header-panel/core-header-panel.html" rel="import"> | |
<link href="../core-menu/core-menu.html" rel="import"> | |
<link href="../core-item/core-item.html" rel="import"> | |
<link href="../core-icon-button/core-icon-button.html" rel="import"> | |
<link href="../core-toolbar/core-toolbar.html" rel="import"> | |
<link href="../core-input/core-input.html" rel="import"> | |
<link href="../core-menu/core-submenu.html" rel="import"> | |
<link href="../google-map/google-map.html" rel="import"> | |
<link href="../google-map/google-map-search.html" rel="import"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="../core-scaffold/core-scaffold.html" rel="import"> | |
<link href="../core-header-panel/core-header-panel.html" rel="import"> | |
<link href="../core-menu/core-menu.html" rel="import"> | |
<link href="../core-item/core-item.html" rel="import"> | |
<link href="../core-icon-button/core-icon-button.html" rel="import"> | |
<link href="../core-toolbar/core-toolbar.html" rel="import"> | |
<link href="../core-menu/core-submenu.html" rel="import"> | |
<link href="../google-map/google-map.html" rel="import"> | |
<polymer-element name="my-element"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script> | |
function sum(x, y) { | |
/** | |
Using the conventional plus (+) opertior | |
for concatenating strings. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Default parameter syntax in ES6 | |
// Until ES5 we were not able to declare a default value to function paramters | |
// ES6 gives us the liberty to do that | |
// Parameters value type has no restriction, it could either be an Integer or a String or an Array or even a JavaScript object | |
// ************************************************* | |
// THE ES5 WAY: Let's see how we use to do it in ES5 | |
// *************************************************/ | |
var objAboutPerson = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
A simple example of default parameter handling inside a JavaScript class which uses a constructor | |
*/ | |
class paramValueExample { | |
constructor(x, y) { | |
this.x = 25; | |
this.y = 50; | |
this.fruits = ['banana', 'apple', 'grapes']; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Declare a JavaScript complex object | |
const user = { | |
name: 'Subrata Sarkar', | |
age: 47, | |
gender: 'Male', | |
location: { | |
address: { | |
aptno: 'D3', | |
bldg: 'City Heights - Phase 9', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
A simple example showing how Multiple return values are handled in ES6 and then further modified it using Object Destructuring. | |
I have used ES6 function syntax and ES6 template literal approach in this example. | |
*/ | |
// Function to return multiple values (properties) bundled inside a JavaScript object. | |
const compoundInterestCalculator = ( amount, roi, compoundingTimesPeryear, years ) => { | |
const maturityAmount = (amount * Math.pow((1 + (roi/(compoundingTimesPeryear*100))), (compoundingTimesPeryear*years))); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
The following code snippet shows how to use named parameters | |
by using the help of Object Destructuring. | |
Function emiCalculator() takes one argument whcih is a destructured object with | |
multiple entries, of which two have default values set (in ES6 we can set default values for parameters) | |
When calling the function we would pass three values i.e. rawPrice and downPayment and emiCount (although it has a | |
default value set) and won't pass any value for 'interestPerAnum'. | |
For destructured parameters we have pass their values like { parameterName: {properyName: value} } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
ES6 has provided us two very powerful methods - Rest Parameters and Spread Operators. | |
In this example I have tried to explain these methods, how they work and what we can get out of them. | |
Rest Parameter and Spread Operator have made code clean and easier to understand. | |
With these methods, the development time has decreased considerably as well. | |
Before going into code example, some key points which I want to mention. | |
1. Both Rest Parameter and Spread Operator use the sanme ‘...’ syntax. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Example 1 | |
The object called 'person' has three properties (location being a nested object) | |
and one method definition. The method showDetail prints values of different properties | |
of the same object where the function is defined. | |
*/ | |
var person = { | |
fullName: 'Subrata Sarkar', | |
jobTitle: 'Web developer', | |
location: { |
OlderNewer