SlideShare a Scribd company logo
1 of 106
Download to read offline
Code Focused Training2015
ES6 : ECMA Script 2015
SYED AWASE
RESEARCHER | ENTREPRENEUR | TECHNOLOGY COACH
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 1
Syed Awase earned his PhD from University of Zurich in GIS, supported by EU V Framework Scholarship from SPIRIT Project (www.geo-spirit.org). He
currently provides consulting services through his startup www.territorialprescience.com and www.sycliq.com
Code Focused Training2015
Why ECMA 2015/ES6?
•Javascript has no standad library
•Javascript won’t run outside the
browser
•The DOM is too slow for rendering
•Javascript is single threaded by
design
•Asynchronous programming -> call
back hell
•Javascript has no packaging or a
linker to tie packages together
• Web resources need to be minified
and zipped for performance
•Javascript is too slow for videogames
•Machine generated output is more
difficult to debug
•Poor performance on mobile devices.
•Ballooning project size and
complexity.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 2
Code Focused Training2015
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 3
http://kangax.github.io/compat-table/es6/
Code Focused Training2015
Can ES6 be used in browsers?
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 4
http://pointedears.de/scripts/test/es-matrix/
EDGE
https://bugs.chromium.org/p/v8/issues/list?q=label:Harmony
https://bugzilla.mozilla.org/show_bug.cgi?id=694100
MODULES HAVE BEEN SEPARATED OUT OF ES6
Code Focused Training2015
Babel Traceur
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 5
Transpilers
https://github.com/google/traceur-compiler
https://babeljs.io/
Code Focused Training2015
ES6 New Features
• Classes
•Modules
• New Methods for Strings and Arrays
•Promises
•Maps, Sets
• Completely new features
•Generators
•Proxies
•WeakMaps
•Reflect API
•Proxy API
• Static typing is not part of ES6.
• Static typing is available in
•Microsoft Typescript : transpiled
to ES5 and thows away the type
information while doing so.
•Facebook Flow: A type checker for
ECMAScript 6 that is based on flow
analysis. It only adds optional type
annotations to the language and
infers and checks types. DOES NOT
HELP IN COMPILING ES6 to ES5.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 6
Code Focused Training2015
Benefits of Static Typing
• Allows you to detect a certain
category of errors earlier, because the
code is analyzed statically (during
development, without running code).
•Static typing is complementary to
testing and catches different errors.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 7
Code Focused Training2015
ECMAScript 6 Tools
Transpilers
Babel Turns Es6+ code into Vanilla ES5 with no runtime
Traceur ES6 Features -> ES5 includes classes, generators, promises, destructuring
pattern, default parameters
ES6IFY Traceur compiler wrapped as a Browserify V2 Platform
Babelify Babel transpiler wrapped as a Browserify transform
Es6-transpiler ES6-> ES5 Includes classes, destructuring, default parameters, spread
ES6-module-transpiler ES6 modules to AMD or CJS
Regenerator Transform ES6 yeild/generator functions to ES5
Jstransform A simple utility for pluggable JS syntax transforms. Comes with a small set of
Es6-> ES5 transforms
Defs ES6 block-scoped const and let varaibles to ES3 vars
Es6_module_transpiler-
rails
ES6 modules in the Rails Asset Pipeline
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 8
Code Focused Training2015
ECMA Script Tools
Transpiler
Sweet.js Macros that compile from ES6 to ES5
Bitovi’s Transpile Converts ES6 to AMD, CHS and StealJS
Regexpu Transform unicode-aware ES6 regular expression to ES5
Lebab Transformation for ES5 Code to ES6 (approximates)
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 9
Code Focused Training2015
Strict mode and ECMAScript 6
• Strict mode was introduced in
ECMAScript 5 to clean up the
language.
•Strict mode introduces three
kinds of breaking changes
1. Syntactic changes: some
previously legal syntax is
forbidden in strict model
• with - lets users add
arbitrary objects to the
chain of variable scope
• Deleting an unqualified
identifier
2. More errors
• Assigning to an undeclared
variable causes a
ReferenceError
• Changing read-only properties
causes a TypeError
3. Different semantics
• Arguments doesn’t track the
current values of parameters
• this is undefined in non-
method functions
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 10
http://exploringjs.com/es6/ch_one-javascript.html
Code Focused Training2015
Running ES6
http://www.es6fiddle.net/
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 11
http://babeljs.io/repl/#?babili=false&evaluate=true&lineWrap=false&presets=es2015%2Cr
eact%2Cstage-2&code=
http://es6console.com/
http://google.github.io/traceur-compiler/demo/repl.html#
Code Focused Training2015
New in ECMA 2015
• Arrow function
• Classes
•Modules
•Block Scope (let/const)
•Extended Object Literal
•Default Params
•Rest Params
•Spread Operator
• Destructuring
•Iterator
•Generator
•Template Literal
•Tail Call Optimization
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 12
Code Focused Training2015
New built-in classes and objects
• Promise
•Map
•Set
•WeakMap/WeakSet
•TypedArray
•Symbol
•Proxy/Reflect
• Improvement of existing classes
•String
•RegExp
•Array
•Object
•Math
•Number
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 13
Code Focused Training2015
Default export/import
• Export : expose a class so that
others can use it by importing it
Import : import external classes to
implement reusable functionality
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 14
Code Focused Training2015
Let and Block scoping
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 15
Destructured assignment
• No Hoisting takes place when we
use let , making sure that the
variable declaration takes place
before it is being used.
Code Focused Training2015
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 16
Code Focused Training2015
Const
• constant is a variable whose
value cannot be changed.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 17
Code Focused Training2015
Block Scope in ES6
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 18
Temporal Dead ZONE
123
2112
Code Focused Training2015
Arrow Functions
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 19
Code Focused Training2015
Arrow Functions
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 20
Code Focused Training2015
Arrow Functions => (fat arrow symbol)
• they are shorthand form of
anonymous function expression that
already exist in javascript.
• this in arrow function uses lexical
scoping, its value is always inherited
from the enclosing scope.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 21
Code Focused Training2015
Arrow Functions
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 22
Code Focused Training2015
String interpolation via Template literals
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 23
ES6ES5
• We can use string interpolation and multi-line strings via template literals
Code Focused Training2015
Default Function Parameters
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 24
Code Focused Training2015
Default Function Parameters
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 25
Code Focused Training2015
Rest parameter in ES2015
• A rest parameter is indicated
by three dots(…) preceding a
named which becomes an Array
containing the rest of the
parameters passed to the
function.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 26
• Allows users to specify that multiple
Independent arguments should be
Combined into an array.
Code Focused Training2015
Spread operator in ES2015
•Allows you to specify an array
that should be split and have its
items passed in as separate
arguments to a function.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 27
Code Focused Training2015
Object Literal Extensions
•
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 28
Code Focused Training2015
Object Literal Extensions
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 29
Code Focused Training2015
For..of Loop
•Allows us to easily
iterate over elements
of a collection.
•For..of iterates over
the values of elements
of a collection not the
keys.
•A collection can be an
array, set, list, custom
collection object etc.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 30
Code Focused Training2015
Octal and Binary Literals
• In ES5, we had to use ‘0’ in
front of the numbers to specify
it’s a octal number., which often
did not work when used in
‘strict mode’
• “0o” is a new way of creating a
number using octal value in ES
2015.
• “0b” lets you create a number
using binary of the number
directly.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 31
Code Focused Training2015
Destructuring
• makes it easier to
work with objects
and arrays in
Javascript.
•Using a pattern
syntax similar to
object and array
literal, we can poke
into data structures
and pick out the
information we
want into variables.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 32
Code Focused Training2015
Modules
• Modules are one of the most
important features of any
programming language. JS lacks this
very basic feature. ES5, AMD was
achieved either using commonJS or
requireJS.
•In ES6 each module is defined in its
own file.
•The functions or variables defined in
a module are not visible outside
unless you explicitly export them
• ES6 modules are declarative in
nature.
• use
•Export to export
•Import to import
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 33
Code Focused Training2015
Basic Module Demo in ECMA 2015
Onemain.js Onemodule.js
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 34
Code Focused Training2015
Named Exports in Modules
• A module can export multiple things
by prefixing their declarations with
the keyword export. These exports
are distinguished by their names and
are called named exports.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 35
Error
Code Focused Training2015
Named Exports in Module
Fourmain.js Fourmodule.js
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 36
Code Focused Training2015
Named Exports in Module
Fivemain.js Fivemodule.js
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 37
Code Focused Training2015
Class in ES2015
• ES6 classes are not something
that is radically new, they are
mainly provided with more
convenient syntax to create old-
school constructor functions.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 38
Code Focused Training2015
Extending Class in ES2015
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 39
Point
ColorPoint
extends
Code Focused Training2015
Class : Additional Insights
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 40
Code Focused Training2015
Class :extends
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 41
Code Focused Training2015
Class: super
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 42
Code Focused Training2015
Static keyword in ES2015
• static properties or class
properties are properties of the
class.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 43
Code Focused Training2015
new.target
• meta property
•Sole purpose is to retrieve the
current value of the current
function environment.
•It is a value that is set when a
function is called
• mainly used in a constructor
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 44
Code Focused Training2015
Symbols in ES2015
• A symbol is a unique and
immutable data type and may be
used as an identifier for object
properties.
•Purpose of a symbol is to
generate a unique identifier, but
we never get to access the
identifier.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 45
Symbols enable access control for object
state
Symbols are a new primitive type
Code Focused Training2015
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 46
Code Focused Training2015
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 47
Code Focused Training2015
Well-known Symbol
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 48
Code Focused Training2015
Object Extensions
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 49
Code Focused Training2015
String Extensions
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 50
Code Focused Training2015
Number Extensions
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 51
Code Focused Training2015
Math Extensions
Hyperbolic Functions
Cosh()
Acosh()
Sinh()
Asinh()
Tanh()
Hypot()
Arithmetic Functions
Cbrt() Cube root
Clz32() Count leading zeros (32 bit integer)
Expm1 Equal to exp(x) -1
Log2() Log base 2
Log10() Log base 10
Log1p() Equal to log(x+1)
Imul() 32 bit integer multiplication
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 52
Sign() The number’ sign: 1, -1, 0, -0,
NaN
Trunc() The integer part of a number
Fround() Round to nearest 32 bit floating
point
Code Focused Training2015
Math Extensions
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 53
Code Focused Training2015
Regular Expressions in ES 2015
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 54
Code Focused Training2015
Function Extensions
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 55
Code Focused Training2015
Iterators in ES2015
• Iterators are used to iterate through
a list of collection.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 56
Code Focused Training2015
Generators in ES2015
• A generator function is a
special type of function that
when invoked automatically
generates a special iterator
called a generator
•Generator functions are
indicated by function* and make
use of the yield operator to
indicate the value to return for
each successive calls to .next()
on the generator.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 57
Code Focused Training2015
Generators in ES2015
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 58
Code Focused Training2015
throw and return
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 59
Code Focused Training2015
Promises
• A Promise specifies some code
to be executed later( as with
events and callbacks and also
explicitly indicates whether the
code succeeded or failed at its
job.
•You can chain promises
together based on success or
failure in ways that make your
code easier to understand and
debug.
• JavaScript engines can only
execute one piece of code at a
time, so they need to keep track
of code that meant to run.
•ES6 has native support for
promises. In ES5, we used to
achieve this using jquery or $q
libraries.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 60
Code Focused Training2015
Promises in ES2015
• used for deferred and
asynchronous computations. A
Promise represents an operation
that hasn’t completed yet, but is
expected in the future.
• Promise has three states
•Pending : initial state, not
fulfilled or rejected.
•Fulfilled: meaning that the
operation completed
successfully
•Rejected: meaning that the
operation failed.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 61
Code Focused Training2015
Promise life cycle in ES2015
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 62
http://bevacqua.github.io/promisees/
Promises visualization playground
https://ponyfoo.com/articles/es6-promises-in-depth
Code Focused Training2015
Promises in ES2015
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 63
Code Focused Training2015
Creating a Promise
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 64
Code Focused Training2015
Promise
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 65
Code Focused Training2015
Promise
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 66
Code Focused Training2015
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 67
Code Focused Training2015
Promise : as a wrapper
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 68
Code Focused Training2015
Promise.all
• There are times when we
trigger multiple async
interactions but only want to
respond when all of them are
completed.
•Promise.all method takes an
array of promises and fires
one callback once they are ALL
resolved.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 69
Code Focused Training2015
Promises Example
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 70
Code Focused Training2015
Promise.race
• Instead of waiting for all promises to be resolved or
rejected, Promise.race triggers as soon as any promise
in the array is resolved or rejected.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 71
Code Focused Training2015
ES2015 Promises
1. Promises give us the ability to
write asynchronous code in a
synchronous fashion, with flat
indentation and a single exception
channel.
2. Help us unify asynchornous APIs
and allow us to wrap non-spec
compliant Promise APIs or
callback APIs with real Promises.
3. Promises give us guarantees of no
race conditions and immutability
of future value represented by the
Promise.
4. Promises cannot be cancelled,
once created it will begin
execution, if you don’t handle
rejections or exceptions, they get
swallowed.
5. No way to determine the state of a
Promise
6. For Recurring values or events, we
can use streams
mechanism/pattern.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 72
Code Focused Training2015
Callbacks
1. Callbacks are functions.
2. Just blocks of code which can be
run in response to events such as
timers going off or messages
being received from the
server.Any function can be a
callback, and every callback is a
function
3. They are defined independently of
the functions they are called from,
they are passed in as arguments.
These functions then store the
callback and call it when the event
actually happens.
Promises
1. Promises are objects.
2. They are objects which store
information about whether or not
those events have happened
yet, and if they have, what their
outcome is.
3. They are created inside of
asynchronous functions ( those
which might not return a
response until later) and then
returned. When an event
happens, the asynchronous
function will update the promise
to notify the outside world.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 73
Code Focused Training2015
Callbacks
4. They can be called multiple times
by the functions they are passed
to.
Promises
4. They can only represent one
event- they are either successful
once or failed once
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 74
Code Focused Training2015
Array Extensions
• Array.of
• is exactly an incarnation of Array
Method, similar to ES5.
• Array.from
•It has 3 arguments, but only the
input is required.
•Input – the arraylike or
iterable object you want to cast
•Map – a mapping function
that’s executed on every item of
input
• context – this binding to use
when called map.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 75
Code Focused Training2015
Array Extensions
Fill Find
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 76
• Only returns the first value it finds in the array
Code Focused Training2015
Array Extensions
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 77
Code Focused Training2015
Array Extensions
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 78
Code Focused Training2015
ArrayBuffers
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 79
Code Focused Training2015
Typed Arrays
1. Int8Array()
2. Uint8Array()
3. Uint8ClampedArray()
4. Int32Array()
5. Uint32Array()
6. Int16Array()
7. Uint16Array()
8. Float32Array()
9. Float64Array()
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 80
Code Focused Training2015
Typed Arrays with ArrayBuffer
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 81
Code Focused Training2015
Map
• Map is a key/value data
structure in ES6. It provides a
better data structure to be used
for hash-maps.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 82
Code Focused Training2015
WeakMap
1. A WeakMap is a subset of Map,
which are not iterable
2. Every key must be an object and
value types are not admitted as
keys.
3. WeakMap enables map keys to
be garbage collected when they
are only being referenced as
WeakMap Keys.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 83
Code Focused Training2015
ES2015 Sets
• Sets are yet another collection
type in ES6. Sets are very similar
to Map.
•Set is also iterable
•They deal with single value or
single objects. The purpose of a
set is to guarantee a uniqueness.
•Set constructor also accepts an
iterable
•Set also has a .size property
•Keys can also be arbitrary
values
•Keys must be unique
•NaN equals NaN when it comes
to Set
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 84
Code Focused Training2015
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 85
Code Focused Training2015
Subclassing Builtins
• we would like to write
extensions to Javascript
language builtins.
•The builtin data structures add
a huge amount of power to the
language, and being able to
create new types that leverage
that power is amazingly useful
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 86
Code Focused Training2015
ES2015 Reflection API
• Object reflection is a language
ability to be able to inspect and
manipulate object properties at
runtime.
•JS has been supporting APIs for
object reflection but these APIs
were not organized under a
namespace and also they threw
exception when they fail to
complete an operation.
• ES2015 introduces a new
object referred as Reflect which
exposes methods for object
reflection.
•These new methods don’t
throw exception on failure
rather they return error, which
makes it easy to write code
involving object reflection.
•Reflect object cannot be used
with new operator as it is not a
constructor© Syed Awase 2015-16 - ECMA 2015 Ground Up! 87
Code Focused Training2015
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 88
console.log(typeof Reflect); => Object
Reflect.construct(target, argumentsList[,newTarget]);
• Not a function Object
• Does not have [[construct]] internal method (can’t use new)
•Does not have a [[call]] internal method (can’t invoke it as a function)
• Check for browser implementations
Code Focused Training2015
Reflect.construct
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 89
The new operator as a function.
Code Focused Training2015
Reflect.apply
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 90
Reflect.apply(target, thisArgument, argumentsList)
Calls a target function with arguments as specified by the args parameter
Code Focused Training2015
Reflect and Prototypes
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 91
• It is the same method as
Object.getPrototypeOf().
•It returns the prototype of
the specified object
Code Focused Training2015
Reflect and Prototypes
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 92
• It sets the prototype of a
specified object to another
object or to null.
Code Focused Training2015
Reflect and Properties
• The static Reflect.get() method
works like getting a property from an
object.
•It returns the value of the property.
•It allows you to get a property on an
object.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 93
Code Focused Training2015
Reflect and Properties
• The static Reflect.set() method
works like setting a property on an
object.
• It allows you to set a property on an
object. It does property assignment
and is like the property accessor
syntax as a function.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 94
Code Focused Training2015
Reflect and Properties
• The static Reflect.has()
method works like the in
operator as a function.
•It allows you to check if a
property is in an object.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 95
Code Focused Training2015
Reflect and Properties
• The static Reflect.ownKeys()
method returns an array of the
target Object’s own property
keys.
• It return value is equivalent to
Object.getOwnPropertyNames(t
arget).concat(Object.getOwnPro
pertySymbols(target)).
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 96
Code Focused Training2015
Reflect and Properties
• The static
Reflect.defineProperty()
method is like
Object.defineProperty(), but
returns a Boolean.
•It allows precise addition to or
modification of a property on an
object.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 97
Code Focused Training2015
Reflect and Properties
• The static Reflect.deleteProperty()
method allows to delete properties.
•It returns a Boolean indicating
whether or not the property was
successfully deleted.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 98
Code Focused Training2015
Reflect and Properties
• The static
Reflect.getOwnPropertyDescri
ptor() method is similar to
Object.getOwnPropertyDescript
or().
• it returns a property descriptor
for the given property if it exists
on the object, undefined
otherwise.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 99
Code Focused Training2015
Reflect and Property Extensions
• The static
Reflect.preventExtensions()
method prevents new properties
from ever being added to an object.
•Prevents future extensions of the
object.
•Similar to Object.preventExtensions()
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 100
Code Focused Training2015
Reflect and Property Extensions
• The static
Reflect.isExtensible() method
determines if an object is
extensible ( whether it can have
new properties added to it).
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 101
Code Focused Training2015
ES2015 Proxies : Proxy API
•Proxy is used to determine
behavior whenever the
properties of a target object are
accessed.
•A handler object can be used
to configure traps for your
Proxy.
• Used for security, profiling,
logging
•New feature in ES2015
• The Proxy object is used to
define custom behavior for
fundamental operations (e.g.
property lookup, assignment,
enumeration, function
invocation, etc)
• Please check with Kangax for
browse compatible
implementations.
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 102
Code Focused Training2015
Proxy Terminology
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 103
Target Object
Or
Function
Handler Object (the Proxy)
TRAPS
Get()
Set()
Apply()
Wrapper
Code Focused Training2015
Get Proxy
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 104
• A trap for getting a property value
• This trap can intercept these operations
•Property access
•Inherited property access
•Reflect.get()
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/get
Code Focused Training2015
Get Proxy
© Syed Awase 2015-16 - ECMA 2015 Ground Up! 105
Code Focused Training2015
sak@sycliq.com
sak@territorialprescience.com
Contact Us
Thank You
We also provide Code Driven Open House Trainings
For code driven trainings for Technology Firms
Reach out to us +91-9035433124
We are hardcore Technologists/Architects/Programmers
trainings are offered by Dr. Syed Awase
Current Offerings
• AngularJS 1.5.x
• Typescript /CoffeeScript /Dart/
• D3.JS/NVD3, HighCharts
• AngularJS 2 (with NodeJS)
• KnockOutJS (with NodeJS)
• BackBoneJS (with NodeJS)
• Ember JS / Ext JS (with NodeJS)
• Raspberry Pi
• Responsive Web Design with Bootstrap, Google Material
Design and KendoUI, Zurb Foundation
• C# ASP.NET MVC , WEB API, WPF
• JAVA , SPRING, HIBERNATE
• Python , Django
• R Statistical Programming
• Android Programming
• Python/Django
• Ruby on Rails
• NoSQL (MongoDB – Essentials & Advanced )
INDIA
HYDERABAD | BANGALORE | CHENNAI | PUNE
OVERSEAS
SINGAPORE | MALAYSIA | DUBAI | EUROPE | NORTH
AMERICA
106© Syed Awase 2015-16 - ECMA 2015 Ground Up!

More Related Content

What's hot

Introducing Java 8
Introducing Java 8Introducing Java 8
Introducing Java 8PT.JUG
 
What's Coming in Java EE 8
What's Coming in Java EE 8What's Coming in Java EE 8
What's Coming in Java EE 8PT.JUG
 
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...Edureka!
 
API SDK Development – Lessons Learned
API SDK Development – Lessons LearnedAPI SDK Development – Lessons Learned
API SDK Development – Lessons LearnedPronovix
 
DevGeekWeek 2017 Inflectra Meetup in Herzliya Presentation
DevGeekWeek 2017 Inflectra Meetup in Herzliya PresentationDevGeekWeek 2017 Inflectra Meetup in Herzliya Presentation
DevGeekWeek 2017 Inflectra Meetup in Herzliya PresentationAdam Sandman
 
Android Auto instrumentation
Android Auto instrumentationAndroid Auto instrumentation
Android Auto instrumentationPrzemek Jakubczyk
 
Lotfy_Samir_new_cv
Lotfy_Samir_new_cv  Lotfy_Samir_new_cv
Lotfy_Samir_new_cv Lotfy Lotfy
 
SAPTECHED 2016 EMEA - 10 Golden Rules for Designing a Custom-Built SAP Fiori...
SAPTECHED 2016  EMEA - 10 Golden Rules for Designing a Custom-Built SAP Fiori...SAPTECHED 2016  EMEA - 10 Golden Rules for Designing a Custom-Built SAP Fiori...
SAPTECHED 2016 EMEA - 10 Golden Rules for Designing a Custom-Built SAP Fiori...Robert Eijpe
 
AEM and Sling
AEM and SlingAEM and Sling
AEM and SlingLo Ki
 
Feature Toggle XP Conference 2016 Kalpana Gulati
Feature Toggle  XP Conference 2016 Kalpana GulatiFeature Toggle  XP Conference 2016 Kalpana Gulati
Feature Toggle XP Conference 2016 Kalpana GulatiXP Conference India
 
Spring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggetsSpring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggetsVirtual Nuggets
 
Lambda Behave - Java 8's Testing Framework
Lambda Behave - Java 8's Testing FrameworkLambda Behave - Java 8's Testing Framework
Lambda Behave - Java 8's Testing Frameworksara stanford
 
Future of an abap developer
Future of an abap developerFuture of an abap developer
Future of an abap developerRobert Eijpe
 
Ask the AEM Community Expert Feb 2016 Session: AEM + Brackets
Ask the AEM Community Expert Feb 2016 Session: AEM + BracketsAsk the AEM Community Expert Feb 2016 Session: AEM + Brackets
Ask the AEM Community Expert Feb 2016 Session: AEM + BracketsAdobeMarketingCloud
 
Building Your API for Longevity
Building Your API for LongevityBuilding Your API for Longevity
Building Your API for LongevityMuleSoft
 
Introduce yourself to java 17
Introduce yourself to java 17Introduce yourself to java 17
Introduce yourself to java 17ankitbhandari32
 
Use Case: Building OSGi Enterprise Applications (QCon 14)
Use Case: Building OSGi Enterprise Applications (QCon 14)Use Case: Building OSGi Enterprise Applications (QCon 14)
Use Case: Building OSGi Enterprise Applications (QCon 14)Carsten Ziegeler
 

What's hot (20)

Introducing Java 8
Introducing Java 8Introducing Java 8
Introducing Java 8
 
What's Coming in Java EE 8
What's Coming in Java EE 8What's Coming in Java EE 8
What's Coming in Java EE 8
 
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
Spring Interview Questions and Answers | Spring Tutorial | Spring Framework T...
 
API SDK Development – Lessons Learned
API SDK Development – Lessons LearnedAPI SDK Development – Lessons Learned
API SDK Development – Lessons Learned
 
DevGeekWeek 2017 Inflectra Meetup in Herzliya Presentation
DevGeekWeek 2017 Inflectra Meetup in Herzliya PresentationDevGeekWeek 2017 Inflectra Meetup in Herzliya Presentation
DevGeekWeek 2017 Inflectra Meetup in Herzliya Presentation
 
Android Auto instrumentation
Android Auto instrumentationAndroid Auto instrumentation
Android Auto instrumentation
 
curriculum_eng_2016
curriculum_eng_2016curriculum_eng_2016
curriculum_eng_2016
 
Lotfy_Samir_new_cv
Lotfy_Samir_new_cv  Lotfy_Samir_new_cv
Lotfy_Samir_new_cv
 
SAPTECHED 2016 EMEA - 10 Golden Rules for Designing a Custom-Built SAP Fiori...
SAPTECHED 2016  EMEA - 10 Golden Rules for Designing a Custom-Built SAP Fiori...SAPTECHED 2016  EMEA - 10 Golden Rules for Designing a Custom-Built SAP Fiori...
SAPTECHED 2016 EMEA - 10 Golden Rules for Designing a Custom-Built SAP Fiori...
 
AEM and Sling
AEM and SlingAEM and Sling
AEM and Sling
 
Feature Toggle XP Conference 2016 Kalpana Gulati
Feature Toggle  XP Conference 2016 Kalpana GulatiFeature Toggle  XP Conference 2016 Kalpana Gulati
Feature Toggle XP Conference 2016 Kalpana Gulati
 
Spring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggetsSpring Framework Tutorial | VirtualNuggets
Spring Framework Tutorial | VirtualNuggets
 
Java Spring Framework
Java Spring FrameworkJava Spring Framework
Java Spring Framework
 
Lambda Behave - Java 8's Testing Framework
Lambda Behave - Java 8's Testing FrameworkLambda Behave - Java 8's Testing Framework
Lambda Behave - Java 8's Testing Framework
 
Future of an abap developer
Future of an abap developerFuture of an abap developer
Future of an abap developer
 
Ask the AEM Community Expert Feb 2016 Session: AEM + Brackets
Ask the AEM Community Expert Feb 2016 Session: AEM + BracketsAsk the AEM Community Expert Feb 2016 Session: AEM + Brackets
Ask the AEM Community Expert Feb 2016 Session: AEM + Brackets
 
THE FUTURE OF ANGULAR JS
THE FUTURE OF ANGULAR JSTHE FUTURE OF ANGULAR JS
THE FUTURE OF ANGULAR JS
 
Building Your API for Longevity
Building Your API for LongevityBuilding Your API for Longevity
Building Your API for Longevity
 
Introduce yourself to java 17
Introduce yourself to java 17Introduce yourself to java 17
Introduce yourself to java 17
 
Use Case: Building OSGi Enterprise Applications (QCon 14)
Use Case: Building OSGi Enterprise Applications (QCon 14)Use Case: Building OSGi Enterprise Applications (QCon 14)
Use Case: Building OSGi Enterprise Applications (QCon 14)
 

Similar to ES6 Features and Tools

Burns jsf-confess-2015
Burns jsf-confess-2015Burns jsf-confess-2015
Burns jsf-confess-2015Edward Burns
 
What are DevOps Application Patterns on AWS…and why do I need them?
What are DevOps Application Patterns on AWS…and why do I need them?What are DevOps Application Patterns on AWS…and why do I need them?
What are DevOps Application Patterns on AWS…and why do I need them?DevOps.com
 
apidays Paris 2022 - Agile API delivery with Feature Toggles, Rafik Ferroukh,...
apidays Paris 2022 - Agile API delivery with Feature Toggles, Rafik Ferroukh,...apidays Paris 2022 - Agile API delivery with Feature Toggles, Rafik Ferroukh,...
apidays Paris 2022 - Agile API delivery with Feature Toggles, Rafik Ferroukh,...apidays
 
Adapt or Die: Serverless Microservices
Adapt or Die: Serverless MicroservicesAdapt or Die: Serverless Microservices
Adapt or Die: Serverless MicroservicesApigee | Google Cloud
 
Advances in Verification - Workshop at BMS College of Engineering
Advances in Verification - Workshop at BMS College of EngineeringAdvances in Verification - Workshop at BMS College of Engineering
Advances in Verification - Workshop at BMS College of EngineeringRamdas Mozhikunnath
 
Acing application lifecycle management in SharePoint
Acing application lifecycle management in SharePointAcing application lifecycle management in SharePoint
Acing application lifecycle management in SharePointJeremy Thake
 
Pitfalls of machine learning in production
Pitfalls of machine learning in productionPitfalls of machine learning in production
Pitfalls of machine learning in productionAntoine Sauray
 
01 demystifying mysq-lfororacledbaanddeveloperv1
01 demystifying mysq-lfororacledbaanddeveloperv101 demystifying mysq-lfororacledbaanddeveloperv1
01 demystifying mysq-lfororacledbaanddeveloperv1Ivan Ma
 
Graal Tutorial at CGO 2015 by Christian Wimmer
Graal Tutorial at CGO 2015 by Christian WimmerGraal Tutorial at CGO 2015 by Christian Wimmer
Graal Tutorial at CGO 2015 by Christian WimmerThomas Wuerthinger
 
Modern ASP.NET Webskills
Modern ASP.NET WebskillsModern ASP.NET Webskills
Modern ASP.NET WebskillsCaleb Jenkins
 
Modern java script features
Modern java script featuresModern java script features
Modern java script featuresKunal Kursija
 
Refactoring Legacy Web Forms for Test Automation
Refactoring Legacy Web Forms for Test AutomationRefactoring Legacy Web Forms for Test Automation
Refactoring Legacy Web Forms for Test AutomationStephen Fuqua
 
IBM - Developing portlets using Script portlet in WP 8001
IBM - Developing portlets using Script portlet in WP 8001IBM - Developing portlets using Script portlet in WP 8001
IBM - Developing portlets using Script portlet in WP 8001Vinayak Tavargeri
 
AppeX and JavaScript Support Enhancements in Cincom Smalltalk
AppeX and JavaScript Support Enhancements in Cincom SmalltalkAppeX and JavaScript Support Enhancements in Cincom Smalltalk
AppeX and JavaScript Support Enhancements in Cincom SmalltalkESUG
 

Similar to ES6 Features and Tools (20)

Burns jsf-confess-2015
Burns jsf-confess-2015Burns jsf-confess-2015
Burns jsf-confess-2015
 
What are DevOps Application Patterns on AWS…and why do I need them?
What are DevOps Application Patterns on AWS…and why do I need them?What are DevOps Application Patterns on AWS…and why do I need them?
What are DevOps Application Patterns on AWS…and why do I need them?
 
SUG Bangalore - Kick Off Session
SUG Bangalore - Kick Off SessionSUG Bangalore - Kick Off Session
SUG Bangalore - Kick Off Session
 
apidays Paris 2022 - Agile API delivery with Feature Toggles, Rafik Ferroukh,...
apidays Paris 2022 - Agile API delivery with Feature Toggles, Rafik Ferroukh,...apidays Paris 2022 - Agile API delivery with Feature Toggles, Rafik Ferroukh,...
apidays Paris 2022 - Agile API delivery with Feature Toggles, Rafik Ferroukh,...
 
10 Useful New Features of ECMA Script 6
10 Useful New Features of ECMA Script 610 Useful New Features of ECMA Script 6
10 Useful New Features of ECMA Script 6
 
MVC 1.0 / JSR 371
MVC 1.0 / JSR 371MVC 1.0 / JSR 371
MVC 1.0 / JSR 371
 
Adapt or Die: Serverless Microservices
Adapt or Die: Serverless MicroservicesAdapt or Die: Serverless Microservices
Adapt or Die: Serverless Microservices
 
powershell.pdf
powershell.pdfpowershell.pdf
powershell.pdf
 
Building APIs with Mule and Spring Boot
Building APIs with Mule and Spring BootBuilding APIs with Mule and Spring Boot
Building APIs with Mule and Spring Boot
 
Advances in Verification - Workshop at BMS College of Engineering
Advances in Verification - Workshop at BMS College of EngineeringAdvances in Verification - Workshop at BMS College of Engineering
Advances in Verification - Workshop at BMS College of Engineering
 
Acing application lifecycle management in SharePoint
Acing application lifecycle management in SharePointAcing application lifecycle management in SharePoint
Acing application lifecycle management in SharePoint
 
Pitfalls of machine learning in production
Pitfalls of machine learning in productionPitfalls of machine learning in production
Pitfalls of machine learning in production
 
Spring framework
Spring frameworkSpring framework
Spring framework
 
01 demystifying mysq-lfororacledbaanddeveloperv1
01 demystifying mysq-lfororacledbaanddeveloperv101 demystifying mysq-lfororacledbaanddeveloperv1
01 demystifying mysq-lfororacledbaanddeveloperv1
 
Graal Tutorial at CGO 2015 by Christian Wimmer
Graal Tutorial at CGO 2015 by Christian WimmerGraal Tutorial at CGO 2015 by Christian Wimmer
Graal Tutorial at CGO 2015 by Christian Wimmer
 
Modern ASP.NET Webskills
Modern ASP.NET WebskillsModern ASP.NET Webskills
Modern ASP.NET Webskills
 
Modern java script features
Modern java script featuresModern java script features
Modern java script features
 
Refactoring Legacy Web Forms for Test Automation
Refactoring Legacy Web Forms for Test AutomationRefactoring Legacy Web Forms for Test Automation
Refactoring Legacy Web Forms for Test Automation
 
IBM - Developing portlets using Script portlet in WP 8001
IBM - Developing portlets using Script portlet in WP 8001IBM - Developing portlets using Script portlet in WP 8001
IBM - Developing portlets using Script portlet in WP 8001
 
AppeX and JavaScript Support Enhancements in Cincom Smalltalk
AppeX and JavaScript Support Enhancements in Cincom SmalltalkAppeX and JavaScript Support Enhancements in Cincom Smalltalk
AppeX and JavaScript Support Enhancements in Cincom Smalltalk
 

More from Dr. Awase Khirni Syed

More from Dr. Awase Khirni Syed (8)

Require js training
Require js trainingRequire js training
Require js training
 
Powershell training material
Powershell training materialPowershell training material
Powershell training material
 
R programming groundup-basic-section-i
R programming groundup-basic-section-iR programming groundup-basic-section-i
R programming groundup-basic-section-i
 
Knockout js
Knockout jsKnockout js
Knockout js
 
Mongo db model relationships with documents
Mongo db model relationships with documentsMongo db model relationships with documents
Mongo db model relationships with documents
 
Mongo db groundup-0-nosql-intro-syedawasekhirni
Mongo db groundup-0-nosql-intro-syedawasekhirniMongo db groundup-0-nosql-intro-syedawasekhirni
Mongo db groundup-0-nosql-intro-syedawasekhirni
 
C# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENTC# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENT
 
SycliQ-AgribusinessInfographik001
SycliQ-AgribusinessInfographik001SycliQ-AgribusinessInfographik001
SycliQ-AgribusinessInfographik001
 

Recently uploaded

(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanyChristoph Pohl
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 

Recently uploaded (20)

(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte GermanySuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
SuccessFactors 1H 2024 Release - Sneak-Peek by Deloitte Germany
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 

ES6 Features and Tools

  • 1. Code Focused Training2015 ES6 : ECMA Script 2015 SYED AWASE RESEARCHER | ENTREPRENEUR | TECHNOLOGY COACH © Syed Awase 2015-16 - ECMA 2015 Ground Up! 1 Syed Awase earned his PhD from University of Zurich in GIS, supported by EU V Framework Scholarship from SPIRIT Project (www.geo-spirit.org). He currently provides consulting services through his startup www.territorialprescience.com and www.sycliq.com
  • 2. Code Focused Training2015 Why ECMA 2015/ES6? •Javascript has no standad library •Javascript won’t run outside the browser •The DOM is too slow for rendering •Javascript is single threaded by design •Asynchronous programming -> call back hell •Javascript has no packaging or a linker to tie packages together • Web resources need to be minified and zipped for performance •Javascript is too slow for videogames •Machine generated output is more difficult to debug •Poor performance on mobile devices. •Ballooning project size and complexity. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 2
  • 3. Code Focused Training2015 © Syed Awase 2015-16 - ECMA 2015 Ground Up! 3 http://kangax.github.io/compat-table/es6/
  • 4. Code Focused Training2015 Can ES6 be used in browsers? © Syed Awase 2015-16 - ECMA 2015 Ground Up! 4 http://pointedears.de/scripts/test/es-matrix/ EDGE https://bugs.chromium.org/p/v8/issues/list?q=label:Harmony https://bugzilla.mozilla.org/show_bug.cgi?id=694100 MODULES HAVE BEEN SEPARATED OUT OF ES6
  • 5. Code Focused Training2015 Babel Traceur © Syed Awase 2015-16 - ECMA 2015 Ground Up! 5 Transpilers https://github.com/google/traceur-compiler https://babeljs.io/
  • 6. Code Focused Training2015 ES6 New Features • Classes •Modules • New Methods for Strings and Arrays •Promises •Maps, Sets • Completely new features •Generators •Proxies •WeakMaps •Reflect API •Proxy API • Static typing is not part of ES6. • Static typing is available in •Microsoft Typescript : transpiled to ES5 and thows away the type information while doing so. •Facebook Flow: A type checker for ECMAScript 6 that is based on flow analysis. It only adds optional type annotations to the language and infers and checks types. DOES NOT HELP IN COMPILING ES6 to ES5. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 6
  • 7. Code Focused Training2015 Benefits of Static Typing • Allows you to detect a certain category of errors earlier, because the code is analyzed statically (during development, without running code). •Static typing is complementary to testing and catches different errors. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 7
  • 8. Code Focused Training2015 ECMAScript 6 Tools Transpilers Babel Turns Es6+ code into Vanilla ES5 with no runtime Traceur ES6 Features -> ES5 includes classes, generators, promises, destructuring pattern, default parameters ES6IFY Traceur compiler wrapped as a Browserify V2 Platform Babelify Babel transpiler wrapped as a Browserify transform Es6-transpiler ES6-> ES5 Includes classes, destructuring, default parameters, spread ES6-module-transpiler ES6 modules to AMD or CJS Regenerator Transform ES6 yeild/generator functions to ES5 Jstransform A simple utility for pluggable JS syntax transforms. Comes with a small set of Es6-> ES5 transforms Defs ES6 block-scoped const and let varaibles to ES3 vars Es6_module_transpiler- rails ES6 modules in the Rails Asset Pipeline © Syed Awase 2015-16 - ECMA 2015 Ground Up! 8
  • 9. Code Focused Training2015 ECMA Script Tools Transpiler Sweet.js Macros that compile from ES6 to ES5 Bitovi’s Transpile Converts ES6 to AMD, CHS and StealJS Regexpu Transform unicode-aware ES6 regular expression to ES5 Lebab Transformation for ES5 Code to ES6 (approximates) © Syed Awase 2015-16 - ECMA 2015 Ground Up! 9
  • 10. Code Focused Training2015 Strict mode and ECMAScript 6 • Strict mode was introduced in ECMAScript 5 to clean up the language. •Strict mode introduces three kinds of breaking changes 1. Syntactic changes: some previously legal syntax is forbidden in strict model • with - lets users add arbitrary objects to the chain of variable scope • Deleting an unqualified identifier 2. More errors • Assigning to an undeclared variable causes a ReferenceError • Changing read-only properties causes a TypeError 3. Different semantics • Arguments doesn’t track the current values of parameters • this is undefined in non- method functions © Syed Awase 2015-16 - ECMA 2015 Ground Up! 10 http://exploringjs.com/es6/ch_one-javascript.html
  • 11. Code Focused Training2015 Running ES6 http://www.es6fiddle.net/ © Syed Awase 2015-16 - ECMA 2015 Ground Up! 11 http://babeljs.io/repl/#?babili=false&evaluate=true&lineWrap=false&presets=es2015%2Cr eact%2Cstage-2&code= http://es6console.com/ http://google.github.io/traceur-compiler/demo/repl.html#
  • 12. Code Focused Training2015 New in ECMA 2015 • Arrow function • Classes •Modules •Block Scope (let/const) •Extended Object Literal •Default Params •Rest Params •Spread Operator • Destructuring •Iterator •Generator •Template Literal •Tail Call Optimization © Syed Awase 2015-16 - ECMA 2015 Ground Up! 12
  • 13. Code Focused Training2015 New built-in classes and objects • Promise •Map •Set •WeakMap/WeakSet •TypedArray •Symbol •Proxy/Reflect • Improvement of existing classes •String •RegExp •Array •Object •Math •Number © Syed Awase 2015-16 - ECMA 2015 Ground Up! 13
  • 14. Code Focused Training2015 Default export/import • Export : expose a class so that others can use it by importing it Import : import external classes to implement reusable functionality © Syed Awase 2015-16 - ECMA 2015 Ground Up! 14
  • 15. Code Focused Training2015 Let and Block scoping © Syed Awase 2015-16 - ECMA 2015 Ground Up! 15 Destructured assignment • No Hoisting takes place when we use let , making sure that the variable declaration takes place before it is being used.
  • 16. Code Focused Training2015 © Syed Awase 2015-16 - ECMA 2015 Ground Up! 16
  • 17. Code Focused Training2015 Const • constant is a variable whose value cannot be changed. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 17
  • 18. Code Focused Training2015 Block Scope in ES6 © Syed Awase 2015-16 - ECMA 2015 Ground Up! 18 Temporal Dead ZONE 123 2112
  • 19. Code Focused Training2015 Arrow Functions © Syed Awase 2015-16 - ECMA 2015 Ground Up! 19
  • 20. Code Focused Training2015 Arrow Functions © Syed Awase 2015-16 - ECMA 2015 Ground Up! 20
  • 21. Code Focused Training2015 Arrow Functions => (fat arrow symbol) • they are shorthand form of anonymous function expression that already exist in javascript. • this in arrow function uses lexical scoping, its value is always inherited from the enclosing scope. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 21
  • 22. Code Focused Training2015 Arrow Functions © Syed Awase 2015-16 - ECMA 2015 Ground Up! 22
  • 23. Code Focused Training2015 String interpolation via Template literals © Syed Awase 2015-16 - ECMA 2015 Ground Up! 23 ES6ES5 • We can use string interpolation and multi-line strings via template literals
  • 24. Code Focused Training2015 Default Function Parameters © Syed Awase 2015-16 - ECMA 2015 Ground Up! 24
  • 25. Code Focused Training2015 Default Function Parameters © Syed Awase 2015-16 - ECMA 2015 Ground Up! 25
  • 26. Code Focused Training2015 Rest parameter in ES2015 • A rest parameter is indicated by three dots(…) preceding a named which becomes an Array containing the rest of the parameters passed to the function. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 26 • Allows users to specify that multiple Independent arguments should be Combined into an array.
  • 27. Code Focused Training2015 Spread operator in ES2015 •Allows you to specify an array that should be split and have its items passed in as separate arguments to a function. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 27
  • 28. Code Focused Training2015 Object Literal Extensions • © Syed Awase 2015-16 - ECMA 2015 Ground Up! 28
  • 29. Code Focused Training2015 Object Literal Extensions © Syed Awase 2015-16 - ECMA 2015 Ground Up! 29
  • 30. Code Focused Training2015 For..of Loop •Allows us to easily iterate over elements of a collection. •For..of iterates over the values of elements of a collection not the keys. •A collection can be an array, set, list, custom collection object etc. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 30
  • 31. Code Focused Training2015 Octal and Binary Literals • In ES5, we had to use ‘0’ in front of the numbers to specify it’s a octal number., which often did not work when used in ‘strict mode’ • “0o” is a new way of creating a number using octal value in ES 2015. • “0b” lets you create a number using binary of the number directly. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 31
  • 32. Code Focused Training2015 Destructuring • makes it easier to work with objects and arrays in Javascript. •Using a pattern syntax similar to object and array literal, we can poke into data structures and pick out the information we want into variables. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 32
  • 33. Code Focused Training2015 Modules • Modules are one of the most important features of any programming language. JS lacks this very basic feature. ES5, AMD was achieved either using commonJS or requireJS. •In ES6 each module is defined in its own file. •The functions or variables defined in a module are not visible outside unless you explicitly export them • ES6 modules are declarative in nature. • use •Export to export •Import to import © Syed Awase 2015-16 - ECMA 2015 Ground Up! 33
  • 34. Code Focused Training2015 Basic Module Demo in ECMA 2015 Onemain.js Onemodule.js © Syed Awase 2015-16 - ECMA 2015 Ground Up! 34
  • 35. Code Focused Training2015 Named Exports in Modules • A module can export multiple things by prefixing their declarations with the keyword export. These exports are distinguished by their names and are called named exports. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 35 Error
  • 36. Code Focused Training2015 Named Exports in Module Fourmain.js Fourmodule.js © Syed Awase 2015-16 - ECMA 2015 Ground Up! 36
  • 37. Code Focused Training2015 Named Exports in Module Fivemain.js Fivemodule.js © Syed Awase 2015-16 - ECMA 2015 Ground Up! 37
  • 38. Code Focused Training2015 Class in ES2015 • ES6 classes are not something that is radically new, they are mainly provided with more convenient syntax to create old- school constructor functions. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 38
  • 39. Code Focused Training2015 Extending Class in ES2015 © Syed Awase 2015-16 - ECMA 2015 Ground Up! 39 Point ColorPoint extends
  • 40. Code Focused Training2015 Class : Additional Insights © Syed Awase 2015-16 - ECMA 2015 Ground Up! 40
  • 41. Code Focused Training2015 Class :extends © Syed Awase 2015-16 - ECMA 2015 Ground Up! 41
  • 42. Code Focused Training2015 Class: super © Syed Awase 2015-16 - ECMA 2015 Ground Up! 42
  • 43. Code Focused Training2015 Static keyword in ES2015 • static properties or class properties are properties of the class. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 43
  • 44. Code Focused Training2015 new.target • meta property •Sole purpose is to retrieve the current value of the current function environment. •It is a value that is set when a function is called • mainly used in a constructor © Syed Awase 2015-16 - ECMA 2015 Ground Up! 44
  • 45. Code Focused Training2015 Symbols in ES2015 • A symbol is a unique and immutable data type and may be used as an identifier for object properties. •Purpose of a symbol is to generate a unique identifier, but we never get to access the identifier. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 45 Symbols enable access control for object state Symbols are a new primitive type
  • 46. Code Focused Training2015 © Syed Awase 2015-16 - ECMA 2015 Ground Up! 46
  • 47. Code Focused Training2015 © Syed Awase 2015-16 - ECMA 2015 Ground Up! 47
  • 48. Code Focused Training2015 Well-known Symbol © Syed Awase 2015-16 - ECMA 2015 Ground Up! 48
  • 49. Code Focused Training2015 Object Extensions © Syed Awase 2015-16 - ECMA 2015 Ground Up! 49
  • 50. Code Focused Training2015 String Extensions © Syed Awase 2015-16 - ECMA 2015 Ground Up! 50
  • 51. Code Focused Training2015 Number Extensions © Syed Awase 2015-16 - ECMA 2015 Ground Up! 51
  • 52. Code Focused Training2015 Math Extensions Hyperbolic Functions Cosh() Acosh() Sinh() Asinh() Tanh() Hypot() Arithmetic Functions Cbrt() Cube root Clz32() Count leading zeros (32 bit integer) Expm1 Equal to exp(x) -1 Log2() Log base 2 Log10() Log base 10 Log1p() Equal to log(x+1) Imul() 32 bit integer multiplication © Syed Awase 2015-16 - ECMA 2015 Ground Up! 52 Sign() The number’ sign: 1, -1, 0, -0, NaN Trunc() The integer part of a number Fround() Round to nearest 32 bit floating point
  • 53. Code Focused Training2015 Math Extensions © Syed Awase 2015-16 - ECMA 2015 Ground Up! 53
  • 54. Code Focused Training2015 Regular Expressions in ES 2015 © Syed Awase 2015-16 - ECMA 2015 Ground Up! 54
  • 55. Code Focused Training2015 Function Extensions © Syed Awase 2015-16 - ECMA 2015 Ground Up! 55
  • 56. Code Focused Training2015 Iterators in ES2015 • Iterators are used to iterate through a list of collection. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 56
  • 57. Code Focused Training2015 Generators in ES2015 • A generator function is a special type of function that when invoked automatically generates a special iterator called a generator •Generator functions are indicated by function* and make use of the yield operator to indicate the value to return for each successive calls to .next() on the generator. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 57
  • 58. Code Focused Training2015 Generators in ES2015 © Syed Awase 2015-16 - ECMA 2015 Ground Up! 58
  • 59. Code Focused Training2015 throw and return © Syed Awase 2015-16 - ECMA 2015 Ground Up! 59
  • 60. Code Focused Training2015 Promises • A Promise specifies some code to be executed later( as with events and callbacks and also explicitly indicates whether the code succeeded or failed at its job. •You can chain promises together based on success or failure in ways that make your code easier to understand and debug. • JavaScript engines can only execute one piece of code at a time, so they need to keep track of code that meant to run. •ES6 has native support for promises. In ES5, we used to achieve this using jquery or $q libraries. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 60
  • 61. Code Focused Training2015 Promises in ES2015 • used for deferred and asynchronous computations. A Promise represents an operation that hasn’t completed yet, but is expected in the future. • Promise has three states •Pending : initial state, not fulfilled or rejected. •Fulfilled: meaning that the operation completed successfully •Rejected: meaning that the operation failed. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 61
  • 62. Code Focused Training2015 Promise life cycle in ES2015 © Syed Awase 2015-16 - ECMA 2015 Ground Up! 62 http://bevacqua.github.io/promisees/ Promises visualization playground https://ponyfoo.com/articles/es6-promises-in-depth
  • 63. Code Focused Training2015 Promises in ES2015 © Syed Awase 2015-16 - ECMA 2015 Ground Up! 63
  • 64. Code Focused Training2015 Creating a Promise © Syed Awase 2015-16 - ECMA 2015 Ground Up! 64
  • 65. Code Focused Training2015 Promise © Syed Awase 2015-16 - ECMA 2015 Ground Up! 65
  • 66. Code Focused Training2015 Promise © Syed Awase 2015-16 - ECMA 2015 Ground Up! 66
  • 67. Code Focused Training2015 © Syed Awase 2015-16 - ECMA 2015 Ground Up! 67
  • 68. Code Focused Training2015 Promise : as a wrapper © Syed Awase 2015-16 - ECMA 2015 Ground Up! 68
  • 69. Code Focused Training2015 Promise.all • There are times when we trigger multiple async interactions but only want to respond when all of them are completed. •Promise.all method takes an array of promises and fires one callback once they are ALL resolved. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 69
  • 70. Code Focused Training2015 Promises Example © Syed Awase 2015-16 - ECMA 2015 Ground Up! 70
  • 71. Code Focused Training2015 Promise.race • Instead of waiting for all promises to be resolved or rejected, Promise.race triggers as soon as any promise in the array is resolved or rejected. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 71
  • 72. Code Focused Training2015 ES2015 Promises 1. Promises give us the ability to write asynchronous code in a synchronous fashion, with flat indentation and a single exception channel. 2. Help us unify asynchornous APIs and allow us to wrap non-spec compliant Promise APIs or callback APIs with real Promises. 3. Promises give us guarantees of no race conditions and immutability of future value represented by the Promise. 4. Promises cannot be cancelled, once created it will begin execution, if you don’t handle rejections or exceptions, they get swallowed. 5. No way to determine the state of a Promise 6. For Recurring values or events, we can use streams mechanism/pattern. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 72
  • 73. Code Focused Training2015 Callbacks 1. Callbacks are functions. 2. Just blocks of code which can be run in response to events such as timers going off or messages being received from the server.Any function can be a callback, and every callback is a function 3. They are defined independently of the functions they are called from, they are passed in as arguments. These functions then store the callback and call it when the event actually happens. Promises 1. Promises are objects. 2. They are objects which store information about whether or not those events have happened yet, and if they have, what their outcome is. 3. They are created inside of asynchronous functions ( those which might not return a response until later) and then returned. When an event happens, the asynchronous function will update the promise to notify the outside world. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 73
  • 74. Code Focused Training2015 Callbacks 4. They can be called multiple times by the functions they are passed to. Promises 4. They can only represent one event- they are either successful once or failed once © Syed Awase 2015-16 - ECMA 2015 Ground Up! 74
  • 75. Code Focused Training2015 Array Extensions • Array.of • is exactly an incarnation of Array Method, similar to ES5. • Array.from •It has 3 arguments, but only the input is required. •Input – the arraylike or iterable object you want to cast •Map – a mapping function that’s executed on every item of input • context – this binding to use when called map. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 75
  • 76. Code Focused Training2015 Array Extensions Fill Find © Syed Awase 2015-16 - ECMA 2015 Ground Up! 76 • Only returns the first value it finds in the array
  • 77. Code Focused Training2015 Array Extensions © Syed Awase 2015-16 - ECMA 2015 Ground Up! 77
  • 78. Code Focused Training2015 Array Extensions © Syed Awase 2015-16 - ECMA 2015 Ground Up! 78
  • 79. Code Focused Training2015 ArrayBuffers © Syed Awase 2015-16 - ECMA 2015 Ground Up! 79
  • 80. Code Focused Training2015 Typed Arrays 1. Int8Array() 2. Uint8Array() 3. Uint8ClampedArray() 4. Int32Array() 5. Uint32Array() 6. Int16Array() 7. Uint16Array() 8. Float32Array() 9. Float64Array() © Syed Awase 2015-16 - ECMA 2015 Ground Up! 80
  • 81. Code Focused Training2015 Typed Arrays with ArrayBuffer © Syed Awase 2015-16 - ECMA 2015 Ground Up! 81
  • 82. Code Focused Training2015 Map • Map is a key/value data structure in ES6. It provides a better data structure to be used for hash-maps. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 82
  • 83. Code Focused Training2015 WeakMap 1. A WeakMap is a subset of Map, which are not iterable 2. Every key must be an object and value types are not admitted as keys. 3. WeakMap enables map keys to be garbage collected when they are only being referenced as WeakMap Keys. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 83
  • 84. Code Focused Training2015 ES2015 Sets • Sets are yet another collection type in ES6. Sets are very similar to Map. •Set is also iterable •They deal with single value or single objects. The purpose of a set is to guarantee a uniqueness. •Set constructor also accepts an iterable •Set also has a .size property •Keys can also be arbitrary values •Keys must be unique •NaN equals NaN when it comes to Set © Syed Awase 2015-16 - ECMA 2015 Ground Up! 84
  • 85. Code Focused Training2015 © Syed Awase 2015-16 - ECMA 2015 Ground Up! 85
  • 86. Code Focused Training2015 Subclassing Builtins • we would like to write extensions to Javascript language builtins. •The builtin data structures add a huge amount of power to the language, and being able to create new types that leverage that power is amazingly useful © Syed Awase 2015-16 - ECMA 2015 Ground Up! 86
  • 87. Code Focused Training2015 ES2015 Reflection API • Object reflection is a language ability to be able to inspect and manipulate object properties at runtime. •JS has been supporting APIs for object reflection but these APIs were not organized under a namespace and also they threw exception when they fail to complete an operation. • ES2015 introduces a new object referred as Reflect which exposes methods for object reflection. •These new methods don’t throw exception on failure rather they return error, which makes it easy to write code involving object reflection. •Reflect object cannot be used with new operator as it is not a constructor© Syed Awase 2015-16 - ECMA 2015 Ground Up! 87
  • 88. Code Focused Training2015 © Syed Awase 2015-16 - ECMA 2015 Ground Up! 88 console.log(typeof Reflect); => Object Reflect.construct(target, argumentsList[,newTarget]); • Not a function Object • Does not have [[construct]] internal method (can’t use new) •Does not have a [[call]] internal method (can’t invoke it as a function) • Check for browser implementations
  • 89. Code Focused Training2015 Reflect.construct © Syed Awase 2015-16 - ECMA 2015 Ground Up! 89 The new operator as a function.
  • 90. Code Focused Training2015 Reflect.apply © Syed Awase 2015-16 - ECMA 2015 Ground Up! 90 Reflect.apply(target, thisArgument, argumentsList) Calls a target function with arguments as specified by the args parameter
  • 91. Code Focused Training2015 Reflect and Prototypes © Syed Awase 2015-16 - ECMA 2015 Ground Up! 91 • It is the same method as Object.getPrototypeOf(). •It returns the prototype of the specified object
  • 92. Code Focused Training2015 Reflect and Prototypes © Syed Awase 2015-16 - ECMA 2015 Ground Up! 92 • It sets the prototype of a specified object to another object or to null.
  • 93. Code Focused Training2015 Reflect and Properties • The static Reflect.get() method works like getting a property from an object. •It returns the value of the property. •It allows you to get a property on an object. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 93
  • 94. Code Focused Training2015 Reflect and Properties • The static Reflect.set() method works like setting a property on an object. • It allows you to set a property on an object. It does property assignment and is like the property accessor syntax as a function. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 94
  • 95. Code Focused Training2015 Reflect and Properties • The static Reflect.has() method works like the in operator as a function. •It allows you to check if a property is in an object. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 95
  • 96. Code Focused Training2015 Reflect and Properties • The static Reflect.ownKeys() method returns an array of the target Object’s own property keys. • It return value is equivalent to Object.getOwnPropertyNames(t arget).concat(Object.getOwnPro pertySymbols(target)). © Syed Awase 2015-16 - ECMA 2015 Ground Up! 96
  • 97. Code Focused Training2015 Reflect and Properties • The static Reflect.defineProperty() method is like Object.defineProperty(), but returns a Boolean. •It allows precise addition to or modification of a property on an object. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 97
  • 98. Code Focused Training2015 Reflect and Properties • The static Reflect.deleteProperty() method allows to delete properties. •It returns a Boolean indicating whether or not the property was successfully deleted. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 98
  • 99. Code Focused Training2015 Reflect and Properties • The static Reflect.getOwnPropertyDescri ptor() method is similar to Object.getOwnPropertyDescript or(). • it returns a property descriptor for the given property if it exists on the object, undefined otherwise. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 99
  • 100. Code Focused Training2015 Reflect and Property Extensions • The static Reflect.preventExtensions() method prevents new properties from ever being added to an object. •Prevents future extensions of the object. •Similar to Object.preventExtensions() © Syed Awase 2015-16 - ECMA 2015 Ground Up! 100
  • 101. Code Focused Training2015 Reflect and Property Extensions • The static Reflect.isExtensible() method determines if an object is extensible ( whether it can have new properties added to it). © Syed Awase 2015-16 - ECMA 2015 Ground Up! 101
  • 102. Code Focused Training2015 ES2015 Proxies : Proxy API •Proxy is used to determine behavior whenever the properties of a target object are accessed. •A handler object can be used to configure traps for your Proxy. • Used for security, profiling, logging •New feature in ES2015 • The Proxy object is used to define custom behavior for fundamental operations (e.g. property lookup, assignment, enumeration, function invocation, etc) • Please check with Kangax for browse compatible implementations. © Syed Awase 2015-16 - ECMA 2015 Ground Up! 102
  • 103. Code Focused Training2015 Proxy Terminology © Syed Awase 2015-16 - ECMA 2015 Ground Up! 103 Target Object Or Function Handler Object (the Proxy) TRAPS Get() Set() Apply() Wrapper
  • 104. Code Focused Training2015 Get Proxy © Syed Awase 2015-16 - ECMA 2015 Ground Up! 104 • A trap for getting a property value • This trap can intercept these operations •Property access •Inherited property access •Reflect.get() https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/handler/get
  • 105. Code Focused Training2015 Get Proxy © Syed Awase 2015-16 - ECMA 2015 Ground Up! 105
  • 106. Code Focused Training2015 sak@sycliq.com sak@territorialprescience.com Contact Us Thank You We also provide Code Driven Open House Trainings For code driven trainings for Technology Firms Reach out to us +91-9035433124 We are hardcore Technologists/Architects/Programmers trainings are offered by Dr. Syed Awase Current Offerings • AngularJS 1.5.x • Typescript /CoffeeScript /Dart/ • D3.JS/NVD3, HighCharts • AngularJS 2 (with NodeJS) • KnockOutJS (with NodeJS) • BackBoneJS (with NodeJS) • Ember JS / Ext JS (with NodeJS) • Raspberry Pi • Responsive Web Design with Bootstrap, Google Material Design and KendoUI, Zurb Foundation • C# ASP.NET MVC , WEB API, WPF • JAVA , SPRING, HIBERNATE • Python , Django • R Statistical Programming • Android Programming • Python/Django • Ruby on Rails • NoSQL (MongoDB – Essentials & Advanced ) INDIA HYDERABAD | BANGALORE | CHENNAI | PUNE OVERSEAS SINGAPORE | MALAYSIA | DUBAI | EUROPE | NORTH AMERICA 106© Syed Awase 2015-16 - ECMA 2015 Ground Up!