JAVASCRIPT FOR THE C# DEVELOPER

Similar documents
DESIGN PATTERNS FOR MERE MORTALS

VERSION ASP.NET CORE APIS

SOLID DESIGN PATTERNS FOR MERE MORTALS

IMPLEMENTING MODEL VIEW VIEW-MODEL IN WINJS

JavaScript. Training Offer for JavaScript Introduction JavaScript. JavaScript Objects

JavaScript I Language Basics

The course is supplemented by numerous hands-on labs that help attendees reinforce their theoretical knowledge of the learned material.

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

Client-Side Web Technologies. JavaScript Part I

SECURING ASP.NET CORE APPLICATIONS

THE RESURGENCE OF WEBFORMS I M NOT DEAD YET! Philip Japikse MVP, MCSD.Net, MCDBA, CSM, CSP

Node.js Training JavaScript. Richard richardrodger.com

Symbols. accessor properties, attributes, creating, adding properties, 8 anonymous functions, 20, 80

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications

Web Application Development

JavaScript: Sort of a Big Deal,

INF5750. Introduction to JavaScript and Node.js

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

JavaScript: More Syntax

TEST DRIVEN DEVELOPMENT FOR T-SQL IT S NOT JUST TESTING FIRST!

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications

JavaScript Lecture 1

Princess Nourah bint Abdulrahman University. Computer Sciences Department

JavaScript for C# Programmers Kevin

CGS 3066: Spring 2015 JavaScript Reference

INF 102 CONCEPTS OF PROG. LANGS FUNCTIONAL COMPOSITION. Instructors: James Jones Copyright Instructors.

JavaScript CS 4640 Programming Languages for Web Applications

JavaScript or: HOW I LEARNED TO STOP WORRYING AND LOVE A CLASSLESS*

Chapter 3 Data Types and Variables

Introduction to Programming Using Java (98-388)

Decaf Language Reference Manual

The results for a few specific cases below are indicated. allequal ([1,1,1,1]) should return true allequal ([1,1,2,1]) should return false

BUILDING WEB APPLICATIONS WITH VISUAL STUDIO 2017: USING.NET CORE AND MODERN JAVASCRIPT FRAMEWORKS BY PHILIP JAPIKSE, BEN DEWEY, KEVIN G

Language Reference Manual simplicity

Scripting for Multimedia LECTURE 3: INTRODUCING JAVASCRIPT

CSC Web Programming. Introduction to JavaScript

Lexical Considerations

By Philip Japikse MVP, MCSD.NET, MCDBA, CSM, CSP Principal Consultant Pinnacle Solutions Group

low and not larger than high. 18 points

JavaScript for PHP Developers

JavaScript Syntax. Web Authoring and Design. Benjamin Kenwright

Expr Language Reference

JavaScript Basics. The Big Picture

Background. Javascript is not related to Java in anyway other than trying to get some free publicity

JavaScript: Coercion, Functions, Arrays

MatchaScript: Language Reference Manual Programming Languages & Translators Spring 2017

PERL Scripting - Course Contents

JavaScript or: How I Learned to Stop Worrying and Love a Classless Loosely Typed Language

Sprite an animation manipulation language Language Reference Manual

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107

INF 212 ANALYSIS OF PROG. LANGS FUNCTION COMPOSITION. Instructors: Crista Lopes Copyright Instructors.

JavaScript CS 4640 Programming Languages for Web Applications

CONTROLLING ASP.NET MVC 4

JavaScript: the language of browser interactions. Claudia Hauff TI1506: Web and Database Technology

JavaScript Basics. Mendel Rosenblum. CS142 Lecture Notes - JavaScript Basics

LESSONS LEARNED: BEING AGILE IN THE WATERFALL SANDBOX

Functional JavaScript. Douglas Crockford Yahoo! Inc.

COMP284 Scripting Languages Lecture 15: JavaScript (Part 2) Handouts

FALL 2017 CS 498RK JAVASCRIPT. Fashionable and Functional!

ASP.NET CORE 2.0: WHAT YOU NEED TO KNOW

JavaScript Lecture 2

1 CS580W-01 Quiz 1 Solution

Typescript on LLVM Language Reference Manual

Javascript Arrays, Object & Functions

Introduction to Visual Basic and Visual C++ Arithmetic Expression. Arithmetic Expression. Using Arithmetic Expression. Lesson 4.

Lexical Considerations

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

3 The Building Blocks: Data Types, Literals, and Variables

Reference Grammar Meta-notation: hfooi means foo is a nonterminal. foo (in bold font) means that foo is a terminal i.e., a token or a part of a token.

Language Fundamentals Summary

Highlights. - Making threads. - Waiting for threads. - Review (classes, pointers, inheritance)

Introduction to JavaScript p. 1 JavaScript Myths p. 2 Versions of JavaScript p. 2 Client-Side JavaScript p. 3 JavaScript in Other Contexts p.

JavaScript Patterns O'REILLY* S toy an Stefanov. Sebastopol. Cambridge. Tokyo. Beijing. Farnham K8ln

Variables and Typing

1 Lexical Considerations

Principles of Programming Languages

JScript Reference. Contents

Part I: Introduction to Functions

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

JavaScript: More Syntax and Using Events

JavaScript. What s wrong with JavaScript?

JavaScript. The Bad Parts. Patrick Behr

Lecture 8 (7.5?): Javascript

Chapter 7 Control I Expressions and Statements

CSC Web Technologies, Spring Web Data Exchange Formats

M1-R4: Programing and Problem Solving using C (JAN 2019)

COMP519 Web Programming Lecture 12: JavaScript (Part 3) Handouts

Index COPYRIGHTED MATERIAL

A.A. 2008/09. Why introduce JavaScript. G. Cecchetti Internet Software Technologies

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.

HTML5 and CSS3 More JavaScript Page 1

The PCAT Programming Language Reference Manual

Decision Making in C

Static Analysis for JavaScript

Pro JavaScript. Development. Coding, Capabilities, and Tooling. Den Odell. Apress"

Tail Calls. CMSC 330: Organization of Programming Languages. Tail Recursion. Tail Recursion (cont d) Names and Binding. Tail Recursion (cont d)

First Midterm Exam CS164, Fall 2007 Oct 2, 2007

Interview Questions of C++

Lesson: Web Programming(6) Omid Jafarinezhad Sharif University of Technology

Transcription:

JAVASCRIPT FOR THE C# DEVELOPER Philip Japikse (@skimedic) skimedic@outlook.com www.skimedic.com/blog Microsoft MVP, ASPInsider, MCSD, MCDBA, CSM, CSP Consultant, Teacher, Writer

Phil.About() Consultant, Coach, Author, Teacher Lynda.com (http://bit.ly/skimediclyndacourses) Apress.com (http://bit.ly/apressbooks) Microsoft MVP, ASPInsider, MCSD, MCDBA, CSM, CSP Founder, Agile Conferences, Inc. http://www.dayofagile.org President, Cincinnati.NET User s Group

The Cincinnati Day of Agile/Cincy.Develop() The annual Cincinnati Day of Agile builds on successful events from past years to present a conference to both introduce those new to Agile and encourage stimulating conversation for those more advanced in the subject. Event takes place Friday, July 28, 2017 in West Chester, OH Sponsors If you are interested in sponsoring, please contact Phil at admin@dayofagile.org for more information. Mailing List If you would like to be added to our mailing list, please email us at admin@dayofagile.org with subscribe as the subject. Website: www.dayofagile.org

JAVASCRIPT GRAMMAR

GRAMMAR IS SIMILAR TO C# Case Sensitive (camel case is convention) Comments (// or /* */) White space is not significant Variables start with character Strings Can use Single or Double Quotes (must match) Escape characters with backslash Statement terminator (;) Be explicit! Place open brace on same line use strict Error: Variable undefined in strict mode

OPERATORS AND DATA TYPES

OPERATORS Standard Order of Operations applies Parenthetical groupings Exponents/Roots (Math.pow(x,y) XeY, Math.sqrt(x)) Multiplication/Division/Remainder (*,/,%) Addition/Subtraction (+,-) Unary Type/To Number/Negation/Logical Not (typeof,+,-,!) Ternary (boolean)? DoIfTrue : DoIfFalse;

OPERATORS Logical And/Logical Or (&&, ) Inequality <, <=, >=, > Equality With type conversion (==,!=) ( 1 == 1) //true Without type conversion (===,!==) ( 1 === 1) //false

CORE DATA TYPES AND VALUES Data Types String Number Double precision 64-bit binary Boolean Array Date RegEx Function Object Built in Values Boolean true, false null undefined NaN isnan( foo ) //true Infinity 10/0

STATEMENTS if (condition) { /* DoIfTrue; */ } else { /* DoIfFalse;*/ } while (false) { /* do work */ } do { /* work */ } while (false); for (var x=0;x<10;x++) { /* do work */} var arr = [1,2]; for (var key in arr) { /* do something */ } try {} catch (ex) {} switch (x) { case 1: /* do something */ break; case 2: /* falls through */ case 3: break; default: }

Data Types Truthiness

ARRAYS

ARRAYS Extremely useful Loosely typed Indices can be strings Properties Length = highest index + 1 Standard Operators indexof/lastindexof sort(function) reverse

ARRAY METHODS foreach(function(index,value) Executes function for each element every(functiontest(value,index)) True if all elements match test some(functiontest(value,index)) True if one element matches test filter(functiontest(value,index)) New array where elements match test join([separator]) Create string from all values map(function(value,index)) Creates a new array from return value of the function reduce[right](function(previousvalue,cu rrentvalue,index) [, initialvalue]) Recursively process the elements

ARRAY METHODS pop Remove and return last element shift Remove and return first element push([items]) Add elements to end and return length unshift([items]) Add elements at start and return length slice(start_pos,length) Returns new array splice(start_pos,length,[items]) Remove items (length!= 0), Adds [items] at start_pos

Array Examples

FUNCTIONS

FUNCTIONS Functions in JavaScript are first class objects Can be named or anonymous Can be passed as arguments to other functions All arguments are optional Additional arguments can be passed in Accessed through the arguments collection

IMMEDIATELY INVOKED FUNCTION EXPRESSIONS (IFFE) Used to ensure all necessary code is executed on load Creates private scope of included variables Default pattern in most libraries

Functions Function Parameters Self Executing Functions

OBJECTS

SIMPLE OBJECTS Create simple objects with name/value pair (similar to JSON) JavaScript is Dynamic Properties can be added at anytime Properties can be removed via delete Validate existence with hasownproperty() Accessed through dot notation or brackets Objects can be nested Properties can be functions

CUSTOM TYPES All features of simple objects Created using a constructor function Create new instances using new Access/Add shared properties through object s prototype Creates pseudo inheritance (copy on write) Can use Object.Create to lock down prototypes Can have static members

Objects

SCOPE & NAMESPACES

SCOPE Only two options Global or Function Blocks don t encapsulate variables Order doesn t matter As long as they are declared, variables get hoisted Can (and should) force explicit scoping use strict

NAMESPACES Encapsulate Variables Much like C#, VB.NET Helps prevent collisions with other frameworks Leverage dynamic nature of JavaScript

Scope and Hoisting Namespaces

CLOSURES

CLOSURES Local variables for a function kept alive after the function has returned Created by using a function inside of a function Internal function can reference local variables inside returned function In C#, this would have been destroyed A nice little tutorial: http://www.javascriptkit.com/javatutors/closures.shtml

Closures, Memoization

JSON

JSON SERIALIZATION JavaScript Object Notation Largely replaced POX and SOAP Converts object graph to string JSON.stringify(myobject) Converts string to object graph JSON.parse(text [,reviver]); JSON.parse( { firstname : Philip, lastname : Japikse } )

JSON

PROMISES

PROMISES Not yet part of the standard Implemented by JQuery, WinJS, NodeJS Similar to await/async Does not necessarily mean multi threaded

PROMISES, PROMISES, PROMISES Promise.then(onComplete, onerror, onprogress).done(oncomplete, onerror, onprogress); ------------------------------------------------- return new WinJS.Promise( function(fdone, ferror, fprogress){ var contacts = JSON.stringify(contactList.slice(0)); FileHandling.saveContactsFile(contacts).then(function () { fdone("saved"); }); } );

Me.Contact() skimedic@outlook.com www.skimedic.com/blog www.twitter.com/skimedic http://bit.ly/skimediclyndacourses http://bit.ly/apressbooks www.hallwayconversations.com Questions?