SlideShare a Scribd company logo
JavaScript for C# Developers
By Sarvesh Kushwaha
What JavaScript Is ? But its not C#
• Strongly Typed and Compiled
• Classical Inheritance
• Classes
• Constructors
• Methods
• Loosely Typed and Dynamic
• Prototypal
• Functions
• Functions
• Functions
C# JavaScript
JavaScript Types
JavaScript has basic types :
 Value Types
 Boolean
 String
 Number
 Reference Types
 Object
 Delegate type
 Function
 Special type
 undefined
 null
var z = y // undefined
var x = null // null
var x = typeof 1 // number
var z = typeof 1.0 // number
var y = typeof true // Boolean
Var c = type of “I m sick of this hello world” //
String
var x = new Object(); // object
var z = new Array(); //object
var f = function(arg1, arg2) {};
// f(1,2); its like func<> in C#.
JavaScript Types Contd..
• Type Coalescing
• Type Detection
“Hi ” + “All” // Hi All (string)
“Hi ” + 1 // Hi 1 (string)
1 + “2025” // 12025 (number)
var x = 1;
var typeName = type of x ; // number
All About JavaScript Functions
• Functions is just an object which has properties and member functions
• Functions can store as variable like anonymous function in C#
function SayHello(s) { alert(“Hello”);}
var a = SayHello.length; // 1 parameter
var b = SayHello.toString(); // return whole function as string
var a = function(s) {alert (“Hello”);}
a(1); //call like a function
a.length; //1
All About JavaScript Functions
• Functions parameters do not matters
• No Overloading
function test(a,b,c)
{ alert(a);
alert(b); alert(c);
}
test(1); // b , c will simply undefined
function foo(a)
{ alert(“Hello”); }
function foo(b,c)
{ alert(“Bye”); }
foo(1); // Bye  huh ?
All About JavaScript Functions
• Arguments object , Remember params in C# ?
function foo(a,b,c)
{
alert(arugments.length);
}
foo (1); // 1
// pass many parameters and access their values
function foo()
{
for(var i = 0;i < arguments.length;i++ )
{
alert(arguments[i]);
}
}
foo(1,2,3);
All About JavaScript Functions
• Function always return a value
• ‘this’ tells the owner of the function
• Supports Closure
function foo(a,b,c){ } // will return undefined
var a = foo() // type of ‘undefined’
function foo(a,b,c){ return; } // will return undefined
function foo(a,b,c){ return “”; } // will return s
var anyobj = { name : “Sarvesh”,
func : function(){ console.log(this.name); }}
anyobj.func() // “Sarvesh”
var x= 1;
function anyfunction() { var y = x; }
//references outside of function remains regardless of lifetime
JavaScript Scope
• Functions creates scope
var a = 1; // Global Scope , Added to window object
function abc()
{
var b = a; //works because of closure , and b is limit to
this function only
}
var c = b; // that will not work
JavaScript Namespacing
• Create a namespace
//Don’t have namespace we can mimic them by
creating a object
// Import namespaces or create a new one
var MyNamespace = MyNamespace || {};
MyNamespace.CurrentDate = function() {
return new Date();
}
JavaScript as Object Oriented language
• Classes : No such thing available in JavaScript , but you can mimic it.
function Employee(name ,department)
{
// public properties
this.name = name;
this.department = department;
//member function
this.creditSalary = function(amount){};
// private properties
var annualPackage = 10000;
}
var emp = new Employee(“Sarvesh”,”Development”);
var getDep = emp.department;
emp.creditSalary(1000);
JavaScript as Object Oriented language
• Read & Write , Read only and Write only properties :
function Employee(name)
{
var _name = name;
Object.defineProperty(this,”name”, {
get : function() { return _name;},
set: function(value) {_name = value;} //don’t include set to make
it read only
});
}
var emp = new Employee(“Sarvesh”);
var name = emp.name;
JavaScript as Object Oriented language
• Static Members
function Employee(name ,department)
{
// public properties
this.name = name;
this.department = department;
}
Employee.Married = “Single”;
var emp = new Employee(“Sarvesh”,”Development”);
var getMarriedStatus = emp.Married; //will not work
getMarriedStatus = Employee.Married; //work
JavaScript as Prototype language
• Why its called prototype language ? Because every object you create in
JavaScript has a prototype object.
• All instance of object shares the prototype members.
• Prototype can be used to add extension methods
function Employee(name ,department)
{// public properties
this.name = name;
this.department = department;
}
Employee.prototype.Married = “Single”;
var emp = new Employee(“Sarvesh”,”Development”);
var getMarriedStatus = emp.Married; //now it will work
Array.prototype.detectLength = function() {return this.length;};
Var a = [“One”,”Two”];
var getLength = a.DetectLength();
Reflection in JavaScript
• Like C# , JavaScript allows us to enumerate members
var Emp= {
name : “Sarvesh”,
Companyname : “Microsoft”,
sendThanks : function() {}
};
for(var property in Emp ) //Object reflection
{
alert(property); // name
alert(Emp[property]); // value
}
//Detect properties
var a = new Employee();
var has = a.hasOwnProperty(“name”); //will return Bool value
var isEnum = a.propertyIsEnumerable(“name”);
Architecting JavaScript files
• Isolates scripts with namespaces
<html>
<script src=“One.js”></script>
<script src=“two.js”></script>
</html>
(function(ns){
ns.customer = function(){
this.name = “”;
};
}(window.mynamespace = window.mynamespace || {} ));
(function(ns){
ns.Emp = function(){
this.name = “”;
};
}(window.mynamespace = window.mynamespace || {} ));
Things which are important to know in
Javascript
• Strict Mode (Use of undefined variable, No Duplicate property name, Cant assign
value to read only property)
• Foreach in C# is diff from JavaScript For-In
• Use JS lint in Visual Studio for Compilation Check
“use strict”;
var a = “hiii”; // will work
y = “hii”; // it will not work
var x = {Salary : “” , Salary : “”} // exception
x.Length = 5; //exception
var a = [“A” , “B” , “C”];
for(var i in a)
{
console.log(i); // 0,1,2 will give index
console.log(a[i]); } // A, B, C
Sarvesh Kushwaha | | | | | |

More Related Content

What's hot (20)

LINQ Inside
LINQ InsideLINQ Inside
LINQ Inside
jeffz
 
Javascript tid-bits
Javascript tid-bitsJavascript tid-bits
Javascript tid-bits
David Atchley
 
Learn JavaScript by modeling Rubik Cube
Learn JavaScript by modeling Rubik CubeLearn JavaScript by modeling Rubik Cube
Learn JavaScript by modeling Rubik Cube
Manoj Kumar
 
Javascript
JavascriptJavascript
Javascript
theacadian
 
JavaScript - Chapter 6 - Basic Functions
 JavaScript - Chapter 6 - Basic Functions JavaScript - Chapter 6 - Basic Functions
JavaScript - Chapter 6 - Basic Functions
WebStackAcademy
 
Angular 2.0: Brighter future?
Angular 2.0: Brighter future?Angular 2.0: Brighter future?
Angular 2.0: Brighter future?
Eugene Zharkov
 
JavaScript Core
JavaScript CoreJavaScript Core
JavaScript Core
François Sarradin
 
Javascript basics for automation testing
Javascript  basics for automation testingJavascript  basics for automation testing
Javascript basics for automation testing
Vikas Thange
 
Things that every JavaScript developer should know by Rachel Appel at FrontCo...
Things that every JavaScript developer should know by Rachel Appel at FrontCo...Things that every JavaScript developer should know by Rachel Appel at FrontCo...
Things that every JavaScript developer should know by Rachel Appel at FrontCo...
DevClub_lv
 
Scala - just good for Java shops?
Scala - just good for Java shops?Scala - just good for Java shops?
Scala - just good for Java shops?
Sarah Mount
 
Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?
Nikita Popov
 
Maintainable JavaScript
Maintainable JavaScriptMaintainable JavaScript
Maintainable JavaScript
Nicholas Zakas
 
MongoDB World 2019: BSON Transpilers: Transpiling from Any Language to Any La...
MongoDB World 2019: BSON Transpilers: Transpiling from Any Language to Any La...MongoDB World 2019: BSON Transpilers: Transpiling from Any Language to Any La...
MongoDB World 2019: BSON Transpilers: Transpiling from Any Language to Any La...
MongoDB
 
Mirah Talk for Boulder Ruby Group
Mirah Talk for Boulder Ruby GroupMirah Talk for Boulder Ruby Group
Mirah Talk for Boulder Ruby Group
baroquebobcat
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
WebStackAcademy
 
使用.NET构建轻量级分布式框架
使用.NET构建轻量级分布式框架使用.NET构建轻量级分布式框架
使用.NET构建轻量级分布式框架
jeffz
 
JavaScript global object, execution contexts & closures
JavaScript global object, execution contexts & closuresJavaScript global object, execution contexts & closures
JavaScript global object, execution contexts & closures
HDR1001
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
Michael Girouard
 
"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues"Javascript" por Tiago Rodrigues
"Javascript" por Tiago Rodrigues
Núcleo de Electrónica e Informática da Universidade do Algarve
 
JavaScript - Chapter 5 - Operators
 JavaScript - Chapter 5 - Operators JavaScript - Chapter 5 - Operators
JavaScript - Chapter 5 - Operators
WebStackAcademy
 
LINQ Inside
LINQ InsideLINQ Inside
LINQ Inside
jeffz
 
Learn JavaScript by modeling Rubik Cube
Learn JavaScript by modeling Rubik CubeLearn JavaScript by modeling Rubik Cube
Learn JavaScript by modeling Rubik Cube
Manoj Kumar
 
JavaScript - Chapter 6 - Basic Functions
 JavaScript - Chapter 6 - Basic Functions JavaScript - Chapter 6 - Basic Functions
JavaScript - Chapter 6 - Basic Functions
WebStackAcademy
 
Angular 2.0: Brighter future?
Angular 2.0: Brighter future?Angular 2.0: Brighter future?
Angular 2.0: Brighter future?
Eugene Zharkov
 
Javascript basics for automation testing
Javascript  basics for automation testingJavascript  basics for automation testing
Javascript basics for automation testing
Vikas Thange
 
Things that every JavaScript developer should know by Rachel Appel at FrontCo...
Things that every JavaScript developer should know by Rachel Appel at FrontCo...Things that every JavaScript developer should know by Rachel Appel at FrontCo...
Things that every JavaScript developer should know by Rachel Appel at FrontCo...
DevClub_lv
 
Scala - just good for Java shops?
Scala - just good for Java shops?Scala - just good for Java shops?
Scala - just good for Java shops?
Sarah Mount
 
Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?Typed Properties and more: What's coming in PHP 7.4?
Typed Properties and more: What's coming in PHP 7.4?
Nikita Popov
 
Maintainable JavaScript
Maintainable JavaScriptMaintainable JavaScript
Maintainable JavaScript
Nicholas Zakas
 
MongoDB World 2019: BSON Transpilers: Transpiling from Any Language to Any La...
MongoDB World 2019: BSON Transpilers: Transpiling from Any Language to Any La...MongoDB World 2019: BSON Transpilers: Transpiling from Any Language to Any La...
MongoDB World 2019: BSON Transpilers: Transpiling from Any Language to Any La...
MongoDB
 
Mirah Talk for Boulder Ruby Group
Mirah Talk for Boulder Ruby GroupMirah Talk for Boulder Ruby Group
Mirah Talk for Boulder Ruby Group
baroquebobcat
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
WebStackAcademy
 
使用.NET构建轻量级分布式框架
使用.NET构建轻量级分布式框架使用.NET构建轻量级分布式框架
使用.NET构建轻量级分布式框架
jeffz
 
JavaScript global object, execution contexts & closures
JavaScript global object, execution contexts & closuresJavaScript global object, execution contexts & closures
JavaScript global object, execution contexts & closures
HDR1001
 
Object Oriented JavaScript
Object Oriented JavaScriptObject Oriented JavaScript
Object Oriented JavaScript
Michael Girouard
 
JavaScript - Chapter 5 - Operators
 JavaScript - Chapter 5 - Operators JavaScript - Chapter 5 - Operators
JavaScript - Chapter 5 - Operators
WebStackAcademy
 

Similar to JavaScript For CSharp Developer (20)

The JavaScript Programming Primer
The JavaScript  Programming PrimerThe JavaScript  Programming Primer
The JavaScript Programming Primer
Mike Wilcox
 
Awesomeness of JavaScript…almost
Awesomeness of JavaScript…almostAwesomeness of JavaScript…almost
Awesomeness of JavaScript…almost
Quinton Sheppard
 
LinkedIn TBC JavaScript 100: Intro
LinkedIn TBC JavaScript 100: IntroLinkedIn TBC JavaScript 100: Intro
LinkedIn TBC JavaScript 100: Intro
Adam Crabtree
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
Solv AS
 
Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?
Mario Camou Riveroll
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury
 
Advanced Javascript
Advanced JavascriptAdvanced Javascript
Advanced Javascript
Dhruvin Shah
 
JavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UXJavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UX
JWORKS powered by Ordina
 
Swift - the future of iOS app development
Swift - the future of iOS app developmentSwift - the future of iOS app development
Swift - the future of iOS app development
openak
 
Let's JavaScript
Let's JavaScriptLet's JavaScript
Let's JavaScript
Paweł Dorofiejczyk
 
JavaScript in 2016
JavaScript in 2016JavaScript in 2016
JavaScript in 2016
Codemotion
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)
Eduard Tomàs
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
Amit Tyagi
 
Dart
DartDart
Dart
anandvns
 
BoxLang JVM Language : The Future is Dynamic
BoxLang JVM Language : The Future is DynamicBoxLang JVM Language : The Future is Dynamic
BoxLang JVM Language : The Future is Dynamic
Ortus Solutions, Corp
 
JavaScript
JavaScriptJavaScript
JavaScript
Ivano Malavolta
 
Lecture 03 - JQuery.pdf
Lecture 03 - JQuery.pdfLecture 03 - JQuery.pdf
Lecture 03 - JQuery.pdf
Lê Thưởng
 
Douglas Crockford: Serversideness
Douglas Crockford: ServersidenessDouglas Crockford: Serversideness
Douglas Crockford: Serversideness
WebExpo
 
JavaScript(Es5) Interview Questions & Answers
JavaScript(Es5)  Interview Questions & AnswersJavaScript(Es5)  Interview Questions & Answers
JavaScript(Es5) Interview Questions & Answers
Ratnala Charan kumar
 
JavaScript (without DOM)
JavaScript (without DOM)JavaScript (without DOM)
JavaScript (without DOM)
Piyush Katariya
 
The JavaScript Programming Primer
The JavaScript  Programming PrimerThe JavaScript  Programming Primer
The JavaScript Programming Primer
Mike Wilcox
 
Awesomeness of JavaScript…almost
Awesomeness of JavaScript…almostAwesomeness of JavaScript…almost
Awesomeness of JavaScript…almost
Quinton Sheppard
 
LinkedIn TBC JavaScript 100: Intro
LinkedIn TBC JavaScript 100: IntroLinkedIn TBC JavaScript 100: Intro
LinkedIn TBC JavaScript 100: Intro
Adam Crabtree
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
Solv AS
 
Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?Static or Dynamic Typing? Why not both?
Static or Dynamic Typing? Why not both?
Mario Camou Riveroll
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury
 
Advanced Javascript
Advanced JavascriptAdvanced Javascript
Advanced Javascript
Dhruvin Shah
 
JavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UXJavaScript Basics and Best Practices - CC FE & UX
JavaScript Basics and Best Practices - CC FE & UX
JWORKS powered by Ordina
 
Swift - the future of iOS app development
Swift - the future of iOS app developmentSwift - the future of iOS app development
Swift - the future of iOS app development
openak
 
JavaScript in 2016
JavaScript in 2016JavaScript in 2016
JavaScript in 2016
Codemotion
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)
Eduard Tomàs
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
Amit Tyagi
 
BoxLang JVM Language : The Future is Dynamic
BoxLang JVM Language : The Future is DynamicBoxLang JVM Language : The Future is Dynamic
BoxLang JVM Language : The Future is Dynamic
Ortus Solutions, Corp
 
Lecture 03 - JQuery.pdf
Lecture 03 - JQuery.pdfLecture 03 - JQuery.pdf
Lecture 03 - JQuery.pdf
Lê Thưởng
 
Douglas Crockford: Serversideness
Douglas Crockford: ServersidenessDouglas Crockford: Serversideness
Douglas Crockford: Serversideness
WebExpo
 
JavaScript(Es5) Interview Questions & Answers
JavaScript(Es5)  Interview Questions & AnswersJavaScript(Es5)  Interview Questions & Answers
JavaScript(Es5) Interview Questions & Answers
Ratnala Charan kumar
 
JavaScript (without DOM)
JavaScript (without DOM)JavaScript (without DOM)
JavaScript (without DOM)
Piyush Katariya
 
Ad

Recently uploaded (20)

Why Indonesia’s $12.63B Alt-Lending Boom Needs Loan Servicing Automation & Re...
Why Indonesia’s $12.63B Alt-Lending Boom Needs Loan Servicing Automation & Re...Why Indonesia’s $12.63B Alt-Lending Boom Needs Loan Servicing Automation & Re...
Why Indonesia’s $12.63B Alt-Lending Boom Needs Loan Servicing Automation & Re...
Prachi Desai
 
Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4
Gaurav Sharma
 
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The SequelMarketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
BradBedford3
 
Generative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its ApplicationsGenerative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its Applications
SandeepKS52
 
Leveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer IntentsLeveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer Intents
Keheliya Gallaba
 
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdfHow to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
QuickBooks Training
 
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptxHow AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
kalichargn70th171
 
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdfThe Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
Varsha Nayak
 
Integrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FMEIntegrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FME
Safe Software
 
Top 11 Fleet Management Software Providers in 2025 (2).pdf
Top 11 Fleet Management Software Providers in 2025 (2).pdfTop 11 Fleet Management Software Providers in 2025 (2).pdf
Top 11 Fleet Management Software Providers in 2025 (2).pdf
Trackobit
 
Online Queue Management System for Public Service Offices [Focused on Municip...
Online Queue Management System for Public Service Offices [Focused on Municip...Online Queue Management System for Public Service Offices [Focused on Municip...
Online Queue Management System for Public Service Offices [Focused on Municip...
Rishab Acharya
 
Providing Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better DataProviding Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better Data
Safe Software
 
Artificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across IndustriesArtificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across Industries
SandeepKS52
 
Rebuilding Cadabra Studio: AI as Our Core Foundation
Rebuilding Cadabra Studio: AI as Our Core FoundationRebuilding Cadabra Studio: AI as Our Core Foundation
Rebuilding Cadabra Studio: AI as Our Core Foundation
Cadabra Studio
 
Agentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Agentic Techniques in Retrieval-Augmented Generation with Azure AI SearchAgentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Agentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Maxim Salnikov
 
Best Inbound Call Tracking Software for Small Businesses
Best Inbound Call Tracking Software for Small BusinessesBest Inbound Call Tracking Software for Small Businesses
Best Inbound Call Tracking Software for Small Businesses
TheTelephony
 
Design by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First DevelopmentDesign by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First Development
Par-Tec S.p.A.
 
Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...
Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...
Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...
Safe Software
 
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps CyclesFrom Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
Marjukka Niinioja
 
Key AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence CompaniesKey AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence Companies
Mypcot Infotech
 
Why Indonesia’s $12.63B Alt-Lending Boom Needs Loan Servicing Automation & Re...
Why Indonesia’s $12.63B Alt-Lending Boom Needs Loan Servicing Automation & Re...Why Indonesia’s $12.63B Alt-Lending Boom Needs Loan Servicing Automation & Re...
Why Indonesia’s $12.63B Alt-Lending Boom Needs Loan Servicing Automation & Re...
Prachi Desai
 
Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4Software Engineering Process, Notation & Tools Introduction - Part 4
Software Engineering Process, Notation & Tools Introduction - Part 4
Gaurav Sharma
 
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The SequelMarketo & Dynamics can be Most Excellent to Each Other – The Sequel
Marketo & Dynamics can be Most Excellent to Each Other – The Sequel
BradBedford3
 
Generative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its ApplicationsGenerative Artificial Intelligence and its Applications
Generative Artificial Intelligence and its Applications
SandeepKS52
 
Leveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer IntentsLeveraging Foundation Models to Infer Intents
Leveraging Foundation Models to Infer Intents
Keheliya Gallaba
 
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdfHow to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
How to Generate Financial Statements in QuickBooks Like a Pro (1).pdf
QuickBooks Training
 
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptxHow AI Can Improve Media Quality Testing Across Platforms (1).pptx
How AI Can Improve Media Quality Testing Across Platforms (1).pptx
kalichargn70th171
 
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdfThe Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
The Future of Open Source Reporting Best Alternatives to Jaspersoft.pdf
Varsha Nayak
 
Integrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FMEIntegrating Survey123 and R&H Data Using FME
Integrating Survey123 and R&H Data Using FME
Safe Software
 
Top 11 Fleet Management Software Providers in 2025 (2).pdf
Top 11 Fleet Management Software Providers in 2025 (2).pdfTop 11 Fleet Management Software Providers in 2025 (2).pdf
Top 11 Fleet Management Software Providers in 2025 (2).pdf
Trackobit
 
Online Queue Management System for Public Service Offices [Focused on Municip...
Online Queue Management System for Public Service Offices [Focused on Municip...Online Queue Management System for Public Service Offices [Focused on Municip...
Online Queue Management System for Public Service Offices [Focused on Municip...
Rishab Acharya
 
Providing Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better DataProviding Better Biodiversity Through Better Data
Providing Better Biodiversity Through Better Data
Safe Software
 
Artificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across IndustriesArtificial Intelligence Applications Across Industries
Artificial Intelligence Applications Across Industries
SandeepKS52
 
Rebuilding Cadabra Studio: AI as Our Core Foundation
Rebuilding Cadabra Studio: AI as Our Core FoundationRebuilding Cadabra Studio: AI as Our Core Foundation
Rebuilding Cadabra Studio: AI as Our Core Foundation
Cadabra Studio
 
Agentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Agentic Techniques in Retrieval-Augmented Generation with Azure AI SearchAgentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Agentic Techniques in Retrieval-Augmented Generation with Azure AI Search
Maxim Salnikov
 
Best Inbound Call Tracking Software for Small Businesses
Best Inbound Call Tracking Software for Small BusinessesBest Inbound Call Tracking Software for Small Businesses
Best Inbound Call Tracking Software for Small Businesses
TheTelephony
 
Design by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First DevelopmentDesign by Contract - Building Robust Software with Contract-First Development
Design by Contract - Building Robust Software with Contract-First Development
Par-Tec S.p.A.
 
Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...
Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...
Scaling FME Flow on Demand with Kubernetes: A Case Study At Cadac Group SaaS ...
Safe Software
 
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps CyclesFrom Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
From Chaos to Clarity - Designing (AI-Ready) APIs with APIOps Cycles
Marjukka Niinioja
 
Key AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence CompaniesKey AI Technologies Used by Indian Artificial Intelligence Companies
Key AI Technologies Used by Indian Artificial Intelligence Companies
Mypcot Infotech
 
Ad

JavaScript For CSharp Developer

  • 1. JavaScript for C# Developers By Sarvesh Kushwaha
  • 2. What JavaScript Is ? But its not C# • Strongly Typed and Compiled • Classical Inheritance • Classes • Constructors • Methods • Loosely Typed and Dynamic • Prototypal • Functions • Functions • Functions C# JavaScript
  • 3. JavaScript Types JavaScript has basic types :  Value Types  Boolean  String  Number  Reference Types  Object  Delegate type  Function  Special type  undefined  null var z = y // undefined var x = null // null var x = typeof 1 // number var z = typeof 1.0 // number var y = typeof true // Boolean Var c = type of “I m sick of this hello world” // String var x = new Object(); // object var z = new Array(); //object var f = function(arg1, arg2) {}; // f(1,2); its like func<> in C#.
  • 4. JavaScript Types Contd.. • Type Coalescing • Type Detection “Hi ” + “All” // Hi All (string) “Hi ” + 1 // Hi 1 (string) 1 + “2025” // 12025 (number) var x = 1; var typeName = type of x ; // number
  • 5. All About JavaScript Functions • Functions is just an object which has properties and member functions • Functions can store as variable like anonymous function in C# function SayHello(s) { alert(“Hello”);} var a = SayHello.length; // 1 parameter var b = SayHello.toString(); // return whole function as string var a = function(s) {alert (“Hello”);} a(1); //call like a function a.length; //1
  • 6. All About JavaScript Functions • Functions parameters do not matters • No Overloading function test(a,b,c) { alert(a); alert(b); alert(c); } test(1); // b , c will simply undefined function foo(a) { alert(“Hello”); } function foo(b,c) { alert(“Bye”); } foo(1); // Bye  huh ?
  • 7. All About JavaScript Functions • Arguments object , Remember params in C# ? function foo(a,b,c) { alert(arugments.length); } foo (1); // 1 // pass many parameters and access their values function foo() { for(var i = 0;i < arguments.length;i++ ) { alert(arguments[i]); } } foo(1,2,3);
  • 8. All About JavaScript Functions • Function always return a value • ‘this’ tells the owner of the function • Supports Closure function foo(a,b,c){ } // will return undefined var a = foo() // type of ‘undefined’ function foo(a,b,c){ return; } // will return undefined function foo(a,b,c){ return “”; } // will return s var anyobj = { name : “Sarvesh”, func : function(){ console.log(this.name); }} anyobj.func() // “Sarvesh” var x= 1; function anyfunction() { var y = x; } //references outside of function remains regardless of lifetime
  • 9. JavaScript Scope • Functions creates scope var a = 1; // Global Scope , Added to window object function abc() { var b = a; //works because of closure , and b is limit to this function only } var c = b; // that will not work
  • 10. JavaScript Namespacing • Create a namespace //Don’t have namespace we can mimic them by creating a object // Import namespaces or create a new one var MyNamespace = MyNamespace || {}; MyNamespace.CurrentDate = function() { return new Date(); }
  • 11. JavaScript as Object Oriented language • Classes : No such thing available in JavaScript , but you can mimic it. function Employee(name ,department) { // public properties this.name = name; this.department = department; //member function this.creditSalary = function(amount){}; // private properties var annualPackage = 10000; } var emp = new Employee(“Sarvesh”,”Development”); var getDep = emp.department; emp.creditSalary(1000);
  • 12. JavaScript as Object Oriented language • Read & Write , Read only and Write only properties : function Employee(name) { var _name = name; Object.defineProperty(this,”name”, { get : function() { return _name;}, set: function(value) {_name = value;} //don’t include set to make it read only }); } var emp = new Employee(“Sarvesh”); var name = emp.name;
  • 13. JavaScript as Object Oriented language • Static Members function Employee(name ,department) { // public properties this.name = name; this.department = department; } Employee.Married = “Single”; var emp = new Employee(“Sarvesh”,”Development”); var getMarriedStatus = emp.Married; //will not work getMarriedStatus = Employee.Married; //work
  • 14. JavaScript as Prototype language • Why its called prototype language ? Because every object you create in JavaScript has a prototype object. • All instance of object shares the prototype members. • Prototype can be used to add extension methods function Employee(name ,department) {// public properties this.name = name; this.department = department; } Employee.prototype.Married = “Single”; var emp = new Employee(“Sarvesh”,”Development”); var getMarriedStatus = emp.Married; //now it will work Array.prototype.detectLength = function() {return this.length;}; Var a = [“One”,”Two”]; var getLength = a.DetectLength();
  • 15. Reflection in JavaScript • Like C# , JavaScript allows us to enumerate members var Emp= { name : “Sarvesh”, Companyname : “Microsoft”, sendThanks : function() {} }; for(var property in Emp ) //Object reflection { alert(property); // name alert(Emp[property]); // value } //Detect properties var a = new Employee(); var has = a.hasOwnProperty(“name”); //will return Bool value var isEnum = a.propertyIsEnumerable(“name”);
  • 16. Architecting JavaScript files • Isolates scripts with namespaces <html> <script src=“One.js”></script> <script src=“two.js”></script> </html> (function(ns){ ns.customer = function(){ this.name = “”; }; }(window.mynamespace = window.mynamespace || {} )); (function(ns){ ns.Emp = function(){ this.name = “”; }; }(window.mynamespace = window.mynamespace || {} ));
  • 17. Things which are important to know in Javascript • Strict Mode (Use of undefined variable, No Duplicate property name, Cant assign value to read only property) • Foreach in C# is diff from JavaScript For-In • Use JS lint in Visual Studio for Compilation Check “use strict”; var a = “hiii”; // will work y = “hii”; // it will not work var x = {Salary : “” , Salary : “”} // exception x.Length = 5; //exception var a = [“A” , “B” , “C”]; for(var i in a) { console.log(i); // 0,1,2 will give index console.log(a[i]); } // A, B, C
  • 18. Sarvesh Kushwaha | | | | | |