This document provides a summary of new features in JavaScript, including let/const block scoping, arrow functions, template strings, classes, generators, async/await, and more. It explains each feature in 1-3 sentences and includes code examples.
Programmation fonctionnelle en JavaScriptLoïc Knuchel
La programmation fonctionnelle permet de faire du code plus modulaire, avec moins de bugs et de manière plus productive !!!
Cette présentation montre comment la programmation fonctionnelle peut tenir se promesse et comment l'appliquer avec JavaScript.
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFabio Collini
Kotlin is a first-class language for Android development since Google I/O 2017. And it’s here to stay!
Thanks to Android Studio it’s really easy to introduce Kotlin in an existing project, the configuration is trivial and then we can convert Java classes to Kotlin using a Alt+Shift+Cmd+K. But the new syntax is the just beginning, using Kotlin we can improve our code making it more readable and simpler to write.
In this talk we’ll see how to use some Kotlin features (for example data classes, collections, coroutines and delegates) to simplify Android development comparing the code with the equivalent “modern” Java code. It’s not fair to compare Kotlin code with plain Java 6 code so the Java examples will use lambdas and some external libraries like RxJava and AutoValue.
Patterns for slick database applicationsSkills Matter
Slick is Typesafe's open source database access library for Scala. It features a collection-style API, compact syntax, type-safe, compositional queries and explicit execution control. Community feedback helped us to identify common problems developers are facing when writing Slick applications. This talk suggests particular solutions to these problems. We will be looking at reducing boiler-plate, re-using code between queries, efficiently modeling object references and more.
Programmation fonctionnelle en JavaScriptLoïc Knuchel
La programmation fonctionnelle permet de faire du code plus modulaire, avec moins de bugs et de manière plus productive !!!
Cette présentation montre comment la programmation fonctionnelle peut tenir se promesse et comment l'appliquer avec JavaScript.
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFabio Collini
Kotlin is a first-class language for Android development since Google I/O 2017. And it’s here to stay!
Thanks to Android Studio it’s really easy to introduce Kotlin in an existing project, the configuration is trivial and then we can convert Java classes to Kotlin using a Alt+Shift+Cmd+K. But the new syntax is the just beginning, using Kotlin we can improve our code making it more readable and simpler to write.
In this talk we’ll see how to use some Kotlin features (for example data classes, collections, coroutines and delegates) to simplify Android development comparing the code with the equivalent “modern” Java code. It’s not fair to compare Kotlin code with plain Java 6 code so the Java examples will use lambdas and some external libraries like RxJava and AutoValue.
Patterns for slick database applicationsSkills Matter
Slick is Typesafe's open source database access library for Scala. It features a collection-style API, compact syntax, type-safe, compositional queries and explicit execution control. Community feedback helped us to identify common problems developers are facing when writing Slick applications. This talk suggests particular solutions to these problems. We will be looking at reducing boiler-plate, re-using code between queries, efficiently modeling object references and more.
Functional programming, though far from new, has gained much traction recently. Functional programming characteristics have started to appear in the PHP world, too. Microframeworks including Silex and Slim, middleware architectures (Stack) and even standards (PSR-7) rely on concepts such as lambdas, referential transparency and immutability, all of which come from functional programming.
I’ll give you a crash course in Erlang, a pragmatic functional language to make you feel familiar with the functional paradigm. By comparing code samples between Erlang and PHP, you’ll find out how and why you should employ functional programming in your PHP applications. You’ll see that functional programming is nothing to be scared of. On the contrary, understanding its concepts broadens your programming horizon and provides you with valuable solutions to your problems.
Functional Programming for OO Programmers (part 2)Calvin Cheng
Code examples demonstrating Functional Programming concepts, with JavaScript and Haskell.
Part 1 can be found here - http://www.slideshare.net/calvinchengx/functional-programming-part01
Source code can be found here - http://github.com/calvinchengx/learnhaskell
Let me know if you spot any errors! Thank you! :-)
Great Scott! C# 7 is almost out!
Time to hop into the DeLorean with Doc Brown. If my calculations are correct, when this baby hits 88 miles per hour, we'll be traveling back to the future with C# 7. Switches? Where we're going, we don't need Switches we got Pattern Matching. Just hold on for one second. Let's get this straight, in the future Tuples will be usable! This will beg the questions. Where are we? When are we? We are in the future and we now have Local Functions and Records.
You'll walk away with a sense of where C# is going and how you can learn about its new features today by looking back to the future. This is heavy.
Gary Bernhardt’s famous WAT talk pokes fun at the weird things in Ruby and JavaScript due to weak typing and operator overloading. But Go can be strange, too. It has its own odd behaviors, some of which we run into every day. Learning about Go’s corner cases teaches us how Go works under the covers.
beyond tellerrand: Mobile Apps with JavaScript – There's More Than WebHeiko Behrens
abstract from http://2011.beyondtellerrand.com
Modern web technologies and responsive design aim at a platform independent code base while promising first-class experience on any mobile device. Even though purely web-based approaches can achieve stunning results, they (still) cannot compete with their native counterpart regarding platform features and integration.
In this talk, I will show you how we can use JavaScript to produce mobile apps that include features such as native UI, push notifications, sensors, and paid distribution. You can expect lots of live demos when I will compare the strengths and weaknesses of various frameworks.
How fast ist it really? Benchmarking in practiceTobias Pfeiffer
“What’s the fastest way of doing this?” - you might ask yourself during development. Sure, you can guess what’s fastest or how long something will take, but do you know? How long does it take to sort a list of 1 Million elements? Are tail-recursive functions always the fastest?
Benchmarking is here to answer these questions. However, there are many pitfalls around setting up a good benchmark and interpreting the results. This talk will guide you through, introduce best practices and show you some surprising benchmarking results along the way.
Functional programming, though far from new, has gained much traction recently. Functional programming characteristics have started to appear in the PHP world, too. Microframeworks including Silex and Slim, middleware architectures (Stack) and even standards (PSR-7) rely on concepts such as lambdas, referential transparency and immutability, all of which come from functional programming.
I’ll give you a crash course in Erlang, a pragmatic functional language to make you feel familiar with the functional paradigm. By comparing code samples between Erlang and PHP, you’ll find out how and why you should employ functional programming in your PHP applications. You’ll see that functional programming is nothing to be scared of. On the contrary, understanding its concepts broadens your programming horizon and provides you with valuable solutions to your problems.
Functional Programming for OO Programmers (part 2)Calvin Cheng
Code examples demonstrating Functional Programming concepts, with JavaScript and Haskell.
Part 1 can be found here - http://www.slideshare.net/calvinchengx/functional-programming-part01
Source code can be found here - http://github.com/calvinchengx/learnhaskell
Let me know if you spot any errors! Thank you! :-)
Great Scott! C# 7 is almost out!
Time to hop into the DeLorean with Doc Brown. If my calculations are correct, when this baby hits 88 miles per hour, we'll be traveling back to the future with C# 7. Switches? Where we're going, we don't need Switches we got Pattern Matching. Just hold on for one second. Let's get this straight, in the future Tuples will be usable! This will beg the questions. Where are we? When are we? We are in the future and we now have Local Functions and Records.
You'll walk away with a sense of where C# is going and how you can learn about its new features today by looking back to the future. This is heavy.
Gary Bernhardt’s famous WAT talk pokes fun at the weird things in Ruby and JavaScript due to weak typing and operator overloading. But Go can be strange, too. It has its own odd behaviors, some of which we run into every day. Learning about Go’s corner cases teaches us how Go works under the covers.
beyond tellerrand: Mobile Apps with JavaScript – There's More Than WebHeiko Behrens
abstract from http://2011.beyondtellerrand.com
Modern web technologies and responsive design aim at a platform independent code base while promising first-class experience on any mobile device. Even though purely web-based approaches can achieve stunning results, they (still) cannot compete with their native counterpart regarding platform features and integration.
In this talk, I will show you how we can use JavaScript to produce mobile apps that include features such as native UI, push notifications, sensors, and paid distribution. You can expect lots of live demos when I will compare the strengths and weaknesses of various frameworks.
How fast ist it really? Benchmarking in practiceTobias Pfeiffer
“What’s the fastest way of doing this?” - you might ask yourself during development. Sure, you can guess what’s fastest or how long something will take, but do you know? How long does it take to sort a list of 1 Million elements? Are tail-recursive functions always the fastest?
Benchmarking is here to answer these questions. However, there are many pitfalls around setting up a good benchmark and interpreting the results. This talk will guide you through, introduce best practices and show you some surprising benchmarking results along the way.
Sperasoft talks about several important aspects of ECMAScript6 - language widely used for client-side scripting on the web, in the form of several well-known implementations such as JavaScript, JScript and ActionScript.
This contains all the slides used in Silicon Valley Code Camp presentation on Sunday Oct 4, 10:45 session on "Amazing new features in JavaScript". At the end ut also includes the last year presentation covering ES 5
Not so long ago Microsoft announced a new language trageting on front-end developers. Everybody's reaction was like: Why?!! Is it just Microsoft darting back to Google?!
So, why a new language? JavaScript has its bad parts. Mostly you can avoid them or workaraund. You can emulate class-based OOP style, modules, scoping and even run-time typing. But that is doomed to be clumsy. That's not in the language design. Google has pointed out these flaws, provided a new language and failed. Will the story of TypeScript be any different?
Think Async: Asynchronous Patterns in NodeJSAdam L Barrett
JavaScript is single threaded, so understanding the async patterns available in the language is critical to creating maintainable NodeJS applications with good performance. In order to master “thinking in async”, we’ll explore the async patterns available in node and JavaScript including standard callbacks, promises, thunks/tasks, the new async/await, the upcoming asynchronous iteration features, streams, CSP and ES Observables.
"Немного о функциональном программирование в JavaScript" Алексей КоваленкоFwdays
Все началось давно, еще в школе, классе эдак 7. Тогда учитель математики впервые произнесла фразу: "Игрек равно эф от икс". В то время я и не догадывался что это самое "эф от икс", является базовым принципом функционального программирования, да и не только функционального.
Functional Programming, Reactive Programming, Transducers, MapReduce и многое другое, так или иначе корнями уходит в то самое, незамысловатое f(x). Это настолько серьезная часть программирования, что ежеминутно, если не ежесекундно, по всему миру на клавиатуре нажимаются клавиши f, u, n, c, t, i, o, n. И нажимаются они именно в этой последовательности.
Пора принять тот факт, что без функционального программирования, программирования не существует!
Пора разобраться. Пора понять для чего нужны функции в программирование, как они должны работать и чем они могут быть полезны в ежедневной работе.
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns
Unlocking Business Potential: Tailored Technology Solutions by Prosigns
Discover how Prosigns, a leading technology solutions provider, partners with businesses to drive innovation and success. Our presentation showcases our comprehensive range of services, including custom software development, web and mobile app development, AI & ML solutions, blockchain integration, DevOps services, and Microsoft Dynamics 365 support.
Custom Software Development: Prosigns specializes in creating bespoke software solutions that cater to your unique business needs. Our team of experts works closely with you to understand your requirements and deliver tailor-made software that enhances efficiency and drives growth.
Web and Mobile App Development: From responsive websites to intuitive mobile applications, Prosigns develops cutting-edge solutions that engage users and deliver seamless experiences across devices.
AI & ML Solutions: Harnessing the power of Artificial Intelligence and Machine Learning, Prosigns provides smart solutions that automate processes, provide valuable insights, and drive informed decision-making.
Blockchain Integration: Prosigns offers comprehensive blockchain solutions, including development, integration, and consulting services, enabling businesses to leverage blockchain technology for enhanced security, transparency, and efficiency.
DevOps Services: Prosigns' DevOps services streamline development and operations processes, ensuring faster and more reliable software delivery through automation and continuous integration.
Microsoft Dynamics 365 Support: Prosigns provides comprehensive support and maintenance services for Microsoft Dynamics 365, ensuring your system is always up-to-date, secure, and running smoothly.
Learn how our collaborative approach and dedication to excellence help businesses achieve their goals and stay ahead in today's digital landscape. From concept to deployment, Prosigns is your trusted partner for transforming ideas into reality and unlocking the full potential of your business.
Join us on a journey of innovation and growth. Let's partner for success with Prosigns.
May Marketo Masterclass, London MUG May 22 2024.pdfAdele Miller
Can't make Adobe Summit in Vegas? No sweat because the EMEA Marketo Engage Champions are coming to London to share their Summit sessions, insights and more!
This is a MUG with a twist you don't want to miss.
top nidhi software solution freedownloadvrstrong314
This presentation emphasizes the importance of data security and legal compliance for Nidhi companies in India. It highlights how online Nidhi software solutions, like Vector Nidhi Software, offer advanced features tailored to these needs. Key aspects include encryption, access controls, and audit trails to ensure data security. The software complies with regulatory guidelines from the MCA and RBI and adheres to Nidhi Rules, 2014. With customizable, user-friendly interfaces and real-time features, these Nidhi software solutions enhance efficiency, support growth, and provide exceptional member services. The presentation concludes with contact information for further inquiries.
How to Position Your Globus Data Portal for Success Ten Good PracticesGlobus
Science gateways allow science and engineering communities to access shared data, software, computing services, and instruments. Science gateways have gained a lot of traction in the last twenty years, as evidenced by projects such as the Science Gateways Community Institute (SGCI) and the Center of Excellence on Science Gateways (SGX3) in the US, The Australian Research Data Commons (ARDC) and its platforms in Australia, and the projects around Virtual Research Environments in Europe. A few mature frameworks have evolved with their different strengths and foci and have been taken up by a larger community such as the Globus Data Portal, Hubzero, Tapis, and Galaxy. However, even when gateways are built on successful frameworks, they continue to face the challenges of ongoing maintenance costs and how to meet the ever-expanding needs of the community they serve with enhanced features. It is not uncommon that gateways with compelling use cases are nonetheless unable to get past the prototype phase and become a full production service, or if they do, they don't survive more than a couple of years. While there is no guaranteed pathway to success, it seems likely that for any gateway there is a need for a strong community and/or solid funding streams to create and sustain its success. With over twenty years of examples to draw from, this presentation goes into detail for ten factors common to successful and enduring gateways that effectively serve as best practices for any new or developing gateway.
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTier1 app
Even though at surface level ‘java.lang.OutOfMemoryError’ appears as one single error; underlyingly there are 9 types of OutOfMemoryError. Each type of OutOfMemoryError has different causes, diagnosis approaches and solutions. This session equips you with the knowledge, tools, and techniques needed to troubleshoot and conquer OutOfMemoryError in all its forms, ensuring smoother, more efficient Java applications.
First Steps with Globus Compute Multi-User EndpointsGlobus
In this presentation we will share our experiences around getting started with the Globus Compute multi-user endpoint. Working with the Pharmacology group at the University of Auckland, we have previously written an application using Globus Compute that can offload computationally expensive steps in the researcher's workflows, which they wish to manage from their familiar Windows environments, onto the NeSI (New Zealand eScience Infrastructure) cluster. Some of the challenges we have encountered were that each researcher had to set up and manage their own single-user globus compute endpoint and that the workloads had varying resource requirements (CPUs, memory and wall time) between different runs. We hope that the multi-user endpoint will help to address these challenges and share an update on our progress here.
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Anthony Dahanne
Les Buildpacks existent depuis plus de 10 ans ! D’abord, ils étaient utilisés pour détecter et construire une application avant de la déployer sur certains PaaS. Ensuite, nous avons pu créer des images Docker (OCI) avec leur dernière génération, les Cloud Native Buildpacks (CNCF en incubation). Sont-ils une bonne alternative au Dockerfile ? Que sont les buildpacks Paketo ? Quelles communautés les soutiennent et comment ?
Venez le découvrir lors de cette session ignite
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxrickgrimesss22
Discover the essential features to incorporate in your Winzo clone app to boost business growth, enhance user engagement, and drive revenue. Learn how to create a compelling gaming experience that stands out in the competitive market.
Check out the webinar slides to learn more about how XfilesPro transforms Salesforce document management by leveraging its world-class applications. For more details, please connect with sales@xfilespro.com
If you want to watch the on-demand webinar, please click here: https://www.xfilespro.com/webinars/salesforce-document-management-2-0-smarter-faster-better/
Experience our free, in-depth three-part Tendenci Platform Corporate Membership Management workshop series! In Session 1 on May 14th, 2024, we began with an Introduction and Setup, mastering the configuration of your Corporate Membership Module settings to establish membership types, applications, and more. Then, on May 16th, 2024, in Session 2, we focused on binding individual members to a Corporate Membership and Corporate Reps, teaching you how to add individual members and assign Corporate Representatives to manage dues, renewals, and associated members. Finally, on May 28th, 2024, in Session 3, we covered questions and concerns, addressing any queries or issues you may have.
For more Tendenci AMS events, check out www.tendenci.com/events
We describe the deployment and use of Globus Compute for remote computation. This content is aimed at researchers who wish to compute on remote resources using a unified programming interface, as well as system administrators who will deploy and operate Globus Compute services on their research computing infrastructure.
Software Engineering, Software Consulting, Tech Lead.
Spring Boot, Spring Cloud, Spring Core, Spring JDBC, Spring Security,
Spring Transaction, Spring MVC,
Log4j, REST/SOAP WEB-SERVICES.
Into the Box Keynote Day 2: Unveiling amazing updates and announcements for modern CFML developers! Get ready for exciting releases and updates on Ortus tools and products. Stay tuned for cutting-edge innovations designed to boost your productivity.
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus
As part of the DOE Integrated Research Infrastructure (IRI) program, NERSC at Lawrence Berkeley National Lab and ALCF at Argonne National Lab are working closely with General Atomics on accelerating the computing requirements of the DIII-D experiment. As part of the work the team is investigating ways to speedup the time to solution for many different parts of the DIII-D workflow including how they run jobs on HPC systems. One of these routes is looking at Globus Compute as a way to replace the current method for managing tasks and we describe a brief proof of concept showing how Globus Compute could help to schedule jobs and be a tool to connect compute at different facilities.
Understanding Globus Data Transfers with NetSageGlobus
NetSage is an open privacy-aware network measurement, analysis, and visualization service designed to help end-users visualize and reason about large data transfers. NetSage traditionally has used a combination of passive measurements, including SNMP and flow data, as well as active measurements, mainly perfSONAR, to provide longitudinal network performance data visualization. It has been deployed by dozens of networks world wide, and is supported domestically by the Engagement and Performance Operations Center (EPOC), NSF #2328479. We have recently expanded the NetSage data sources to include logs for Globus data transfers, following the same privacy-preserving approach as for Flow data. Using the logs for the Texas Advanced Computing Center (TACC) as an example, this talk will walk through several different example use cases that NetSage can answer, including: Who is using Globus to share data with my institution, and what kind of performance are they able to achieve? How many transfers has Globus supported for us? Which sites are we sharing the most data with, and how is that changing over time? How is my site using Globus to move data internally, and what kind of performance do we see for those transfers? What percentage of data transfers at my institution used Globus, and how did the overall data transfer performance compare to the Globus users?
In software engineering, the right architecture is essential for robust, scalable platforms. Wix has undergone a pivotal shift from event sourcing to a CRUD-based model for its microservices. This talk will chart the course of this pivotal journey.
Event sourcing, which records state changes as immutable events, provided robust auditing and "time travel" debugging for Wix Stores' microservices. Despite its benefits, the complexity it introduced in state management slowed development. Wix responded by adopting a simpler, unified CRUD model. This talk will explore the challenges of event sourcing and the advantages of Wix's new "CRUD on steroids" approach, which streamlines API integration and domain event management while preserving data integrity and system resilience.
Participants will gain valuable insights into Wix's strategies for ensuring atomicity in database updates and event production, as well as caching, materialization, and performance optimization techniques within a distributed system.
Join us to discover how Wix has mastered the art of balancing simplicity and extensibility, and learn how the re-adoption of the modest CRUD has turbocharged their development velocity, resilience, and scalability in a high-growth environment.
How Recreation Management Software Can Streamline Your Operations.pptxwottaspaceseo
Recreation management software streamlines operations by automating key tasks such as scheduling, registration, and payment processing, reducing manual workload and errors. It provides centralized management of facilities, classes, and events, ensuring efficient resource allocation and facility usage. The software offers user-friendly online portals for easy access to bookings and program information, enhancing customer experience. Real-time reporting and data analytics deliver insights into attendance and preferences, aiding in strategic decision-making. Additionally, effective communication tools keep participants and staff informed with timely updates. Overall, recreation management software enhances efficiency, improves service delivery, and boosts customer satisfaction.
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar
The European Union Agency for Law Enforcement Cooperation (Europol) has suffered an alleged data breach after a notorious threat actor claimed to have exfiltrated data from its systems. Infamous data leaker IntelBroker posted on the even more infamous BreachForums hacking forum, saying that Europol suffered a data breach this month.
The alleged breach affected Europol agencies CCSE, EC3, Europol Platform for Experts, Law Enforcement Forum, and SIRIUS. Infiltration of these entities can disrupt ongoing investigations and compromise sensitive intelligence shared among international law enforcement agencies.
However, this is neither the first nor the last activity of IntekBroker. We have compiled for you what happened in the last few days. To track such hacker activities on dark web sources like hacker forums, private Telegram channels, and other hidden platforms where cyber threats often originate, you can check SOCRadar’s Dark Web News.
Stay Informed on Threat Actors’ Activity on the Dark Web with SOCRadar!
5. let - block scope variable declaration
- block scope variable declaration
if(true) {
let x = 1;
}
console.log(x); // ReferenceError: x is not defined
for(let val of [1, 2, 3, 5]) {
/*...*/
}
console.log(val); // ReferenceError: val is not defined
6. let - block scope variable declaration
- does not hoist (TDZ)
if(true) {
console.log(x); // ReferenceError: foo is not defined
let x = 42;
}
7. const
- similar to let
- must be initialized on declaration
const x; // SyntaxError: missing = in const declaration
- fail silently on reassignment (firefox and chrome)
const x = 1;
x = -1; // fails silently
- throws error on redeclaration
const x = 3.14159;
const x = 2.71828; // TypeError: redeclaration of const x
8. arrow functions - improved syntax
let inc = function(a) { return a + 1; };
let sum = function(a, b) { return a + b; };
let arr = [1, 2, 3, 7, 22];
arr.map(function(n) { return n + 2; })
.filter(function(n) { return n > 8; });
let inc = a => a + 1;
let sum = (a, b) => a + b;
let arr = [1, 2, 3, 7, 22];
arr.map(n => n + 2).filter(n => n > 8);
9. arrow functions - lexical “this”
<button id="btn">Click</button>
<script>
function Widget() {
this.clickCounter = 0; // (1)
document.querySelector('#btn').addEventListener('click', function() {
this.clickCounter++; // “this” here is different from “this” on line (1)
console.log(this.clickCounter);
});
};
var mywidget = new Widget();
</script>
10. arrow functions - lexical “this”
<button id="btn">Click</button>
<script>
function Widget() {
this.clickCounter = 0;
var self = this;
document.querySelector('#btn').addEventListener('click', function() {
self.clickCounter++; // use “self” instead of “this”
console.log(this.clickCounter);
});
};
var mywidget = new Widget();
</script>
11. arrow functions - lexical “this”
<button id="btn">Click</button>
<script>
function Widget() {
this.clickCounter = 0; // (1)
document.querySelector('#btn').addEventListener('click', () => {
this.clickCounter++; // “this” here is the same as “this” from line (1)
console.log(this.clickCounter);
});
};
var mywidget = new Widget();
</script>
12. arrow functions - nice for higher order functions
let notEquals = function(a) {
return function(b) {
return a !== b;
}
};
let notEquals = a => b => a === b;
[2, 3, 5, 7, 11].filter(notEquals(5)); // [2, 3, 7, 11]
// notEquals(5) == b => 5 !== b
13. for...of loops
- iterates over values
let arr = [2, 7, 1, 8, 2, 8];
for(let index in arr) {
console.log(index); // 0, 1, 2, 3, 4, 5
}
for(let value of arr) {
console.log(value); // 2, 7, 1, 8, 2, 8
}
14. tail call optimisation
- tail call is when the last thing a function does is to call another function
- it reuses the current stack frame
- it encourages the use of recursive functions and generally programming in a
functional style
15. default function parameters
function fuu(a, b = 1) {
console.log(‘a =’, a, ‘;‘, ‘b =’, b);
}
fuu(); // a = undefined; b = 1
fuu(2); // a = 2; b = 1
fuu(2, 3); // a = 2; b = 3
16. rest parameters
- accumulate the rest of the parameters from a function call
function baar(a, b, ...c) {
console.log(a, b, c);
}
baar(1); // 1 undefined Array[ ]
baar(1, 4); // 1 4 Array[ ]
baar(1, 4, 11); // 1 4 Array[11]
baar(1, 4, 11, 30); // 1 4 Array[11, 30]
17. spread operator
- expands an iterator where multiple values are expected
fn(...[1, 2, 3]); // equivalent to fn(1, 2, 3)
fn(1, 2, …[7, 41]); // equivalent to fn(1, 2, 7, 41)
let a = [1, 2], b = [4, 5, 6];
let c = [3, 4, ...a]; // c = [3, 4, 1, 2]
let d = [...a, ...b]; // d = [1, 2, 4, 5, 6]
18. object literal extensions
- computed properties
let a = ‘b’;
let c = {
[a]: 4,
[‘a’ + a + ‘c’]: 5
};
console.log(c.b); // 4
console.log(c.abc); // 5
19. object literal extensions
- shorthand properties
let x = 1, y = 2;
let obj;
obj = {x, y, z: 3}; // equivalent to “obj = {x: x, y: y, z: 3}”
- shorthand methods
obj = { sum(a, b) { return a + b; } }
obj.sum(6, 11); // 17
20. object literal extensions
- computed shorthand methods
let myMethod = ‘sum’;
let obj = { [myMethod](a, b) { return a + b; } };
obj.sum(6, 11); // 17
21. template strings
let s = `just made you read this`;
let five = 5,
t = `2 + 2 is ${2 + 2} not ${five}`;
// multiline
let criticilor = `Critici voi, cu flori desarte,
Care roade n-ati adus
E usor a scrie versuri
Când nimic nu ai de spus.
(Mihai Eminescu)`;
22. template strings - tag functions
function mytag(strings, ...values) {
console.log(strings[0]); // “roses are not “
console.log(strings[1]); // “, violets are not “
console.log(values[0]); // “blue”
console.log(values[1]); // “red”
return ‘anything you want’;
}
let r = ‘red’, b = ‘blu’;
mytag`roses are not ${b + ‘e’}, violets are not ${r}`; // ”anything you want”
23. destructuring
let [a, b, c] = [-1, -2, -3];
console.log(‘a =’, a, ‘b =’, b, ‘d !=’, c); // a = -1 b = -2 d != -3
let [ , , d] = [4, 5, -6];
console.log(‘d =’, d); // d = -6
let [e, [f, [g]]] = [7, [8, [9]]];
let [first, ...rest] = [‘first’, ‘r’, ‘e’, ‘s’, ‘t’];
console.log(‘first =‘, first, ‘rest =’, rest); // first = ‘first’ rest = [‘r’, ‘e’, ‘s’, ‘t’]
24. let {name: theName, age} = {name: ‘4real Superman Wheaton’, age: 31};
console.log(‘name =’, theName); // name = “4real Superman Wheaton”
console.log(‘age =’, age); // age = 31
let nested = {very: [‘little’, {baby: ‘bird’}] },
{very: [little, {baby}] } = nested;
console.log(‘little =’, little, ‘baby =’, bird); // little = “little” baby = “bird”
let [a = 1, b = 2] = [3]; // a = 3, b = 2
let {w: y = ‘z’} = {v: ‘v’}; // y = ‘z’
destructuring
26. - syntactic sugar over prototypal inheritance
- fundamentally they are functions and just as functions they can have both
forms (as declarations and as expressions)
class
class declaration
class Point {
constructor(x, y) {
this.x = x;
this.y = y;
}
}
class expression
let Point = class {
constructor(x, y) {
this.x = x;
this.y = y;
}
}
28. class ColorPoint extends Point {
constructor(x, y, color) {
super(x, y);
this.color = color;
}
}
let cp = new ColorPoint(1, 1, ‘green’));
class - extends and super keywords
29. - generators are functions which can be exited and later re-entered
- their context (variable bindings) will be saved across re-entrances
- returns an iterator
function* idMaker() {
let index = 0;
while(index < 3) yield index++;
}
let gen = idMaker();
console.log(gen.next()); // {value: 0, done: false}
console.log(gen.next()); // {value: 1, done: false}
console.log(gen.next()); // {value: 2, done: false}
console.log(gen.next()); // {value: undefined, done: true}
generators
31. Differences between objects and maps:
● An Object has a prototype, so there are default keys in the map. This could
be bypassed by using map = Object.create(null) since ES5, but was
seldomly done.
● The keys of an Object are Strings and Symbols, where they can be any
value for a Map.
● You can get the size of a Map easily while you have to manually keep track
of size for an Object.
Map - new Map([iterable])
32. - the Set object lets you store unique values of any type, whether primitive
values or object references.
- you can iterate its elements in insertion order
Set - new Set([iterable]);
33. - asynchronous code written in a synchronous manner
- syntactic sugar over generators
function getAPromise() {
return new Promise(resolve => setTimeout(() => resolve(‘hello!’), 3000));
}
async function doStuff() {
let value = await getAPromise();
console.log(‘value of the promise is’, value);
}
doStuff(); // value of the promise is hello!
async/await - ES7 (stage 3)
34. function getData(url) {
return fetch(url);
}
(async function() {
let urls = [‘users/1’, ‘users/2’, ‘users/3’];
for(let data of urls.map(getData)) { // makes requests in parallel
console.log((await data).name); // logs the user names in order
}
}());
async/await - ES7 (stage 3)
35. - asynchronously observing the changes to an object
- it provides a stream of changes in the order in which they occur
let obj = {foo: 0, bar: 1};
Object.observe(obj, function(changes) {
console.log(changes);
});
obj.baz = 2; // [{name: 'baz', object: <obj>, type: 'add'}]
obj.foo = 'hello'; // [{name: 'foo', object: <obj>, type: 'update', oldValue: 0}]
delete obj.baz; // [{name: 'baz', object: <obj>, type: 'delete', oldValue: 2}]
Object.defineProperty(obj, 'foo', {writable: false});
// [{name: 'foo', object: <obj>, type: 'reconfigure'}]
Object.observe - ES7 (stage 2)
36. - proposal for an Observable type
- used to model push-based data sources such as DOM events, timer
intervals, sockets and others
- can be composed with higher-order combinators
- they do not start emitting data until an observer has subscribed
Observables - ES7 (stage 1)
37. function listen(element, eventName) {
return new Observable(observer => {
// Create an event handler which sends data to the observer
let handler = event => observer.next(event);
// Attach the event handler
element.addEventListener(eventName, handler, true);
});
}
Observables - ES7 (stage 1)
38. // Return an observable of special key down commands
function commandKeys(element) {
let keyCommands = { "38": "up", "40": "down" };
return listen(element, "keydown")
.filter(event => event.keyCode in keyCommands)
.map(event => keyCommands[event.keyCode])
}
commandKeys(inputElement).subscribe({
next(val) { console.log("Received key command: " + val) }, // “up” “down” “up” “up” “down” “up”
// error(err) { console.log("Received an error: " + err) },
// complete() { console.log("Stream complete") }
});
Observables - ES7 (stage 1)
39. A decorator is:
- an expression
- that evaluates to a function
- that takes the target, name, and property descriptor as arguments
- and optionally returns a property descriptor to install on the target object
class Person {
@nonenumerable
get kidCount() { return this.children.length; }
}
function nonenumerable(target, name, descriptor) {
descriptor.enumerable = false;
return descriptor;
}
class and property decorators - ES7 (stage 1)
40. - It is also possible to decorate the class itself. In this case, the decorator
takes the target constructor.
@annotation
class MyClass { }
function annotation(target) {
// Add a property on target
target.annotated = true;
}
class and property decorators - ES7 (stage 1)
41. - since decorators are expressions, decorators can take additional arguments
and act like a factory
class C {
@enumerable(false)
method() { }
}
function enumerable(value) {
return function (target, key, descriptor) {
descriptor.enumerable = value;
return descriptor;
}
}
class and property decorators - ES7 (stage 1)