A computer program is a list of "instructions" to be "executed" by a computer.
In a programming language, these programming instructions are called statements.
A JavaScript program is a list of programming statements.
JavaScript statements are composed of:
Values, Operators, Expressions, Keywords, and Comments.
This statement tells the browser to write "Hello Dolly." inside an HTML element with id="demo":
JavaScript Data Types
JavaScript variables can hold many data types: numbers, strings, objects and more.
In programming, data types is an important concept.
To be able to operate on variables, it is important to know something about the type.
In JavaScript, almost "everything" is an object.
-Booleans can be objects (if defined with the new keyword)
-Numbers can be objects (if defined with the new keyword)
-Strings can be objects (if defined with the new keyword)
-Dates are always objects
-Maths are always objects
-Regular expressions are always objects
-Arrays are always objects
-Functions are always objects
-Objects are always objects
A JavaScript function is a block of code designed to perform a particular task.
Why Functions?
You can reuse code: Define the code once, and use it many times. You can use the same code many times with different arguments, to produce different results.
This the slide stack for the two videos on Data types in my YouTube series on JavaScript. The videos are at https://www.youtube.com/watch?v=UAtJXkGggOU and https://www.youtube.com/watch?v=H2sjsGZyYaw
JavaScript Arithmetic Operators
Arithmetic operators are used to perform arithmetic between variables and/or values.
JavaScript Assignment Operators
Assignment operators are used to assign values to JavaScript variables.
JavaScript String Operators
The + operator, and the += operator can also be used to concatenate (add) strings.
Comparison Operators
Comparison operators are used in logical statements to determine equality or difference between variables or values.
Conditional (Ternary) Operator
The conditional operator assigns a value to a variable based on a condition.
Logical Operators
Logical operators are used to determine the logic between variables or values.
JavaScript Bitwise Operators
Bit operators work on 32 bits numbers. Any numeric operand in the operation is converted into a 32 bit number. The result is converted back to a JavaScript number.
The delete Operator
The delete operator deletes a property from an object:
JavaScript - Chapter 9 - TypeConversion and Regular Expressions WebStackAcademy
Type Conversion:
JavaScript is loosely typed language and most of the time operators automatically convert a value to the right type but there are also cases when we need to explicitly do type conversions.
While JavaScript provides numerous ways to convert data from one type to another but there are two most common data conversions :
Converting Values to String
Converting Values to Numbers
Regular Expressions:
A regular expression is an object that describes a pattern of characters.
The JavaScript RegExp class represents regular expressions, and both String and RegExp define methods that use regular expressions to perform powerful pattern-matching and search-and-replace functions on text.
In JavaScript, almost "everything" is an object.
-Booleans can be objects (if defined with the new keyword)
-Numbers can be objects (if defined with the new keyword)
-Strings can be objects (if defined with the new keyword)
-Dates are always objects
-Maths are always objects
-Regular expressions are always objects
-Arrays are always objects
-Functions are always objects
-Objects are always objects
A JavaScript function is a block of code designed to perform a particular task.
Why Functions?
You can reuse code: Define the code once, and use it many times. You can use the same code many times with different arguments, to produce different results.
This the slide stack for the two videos on Data types in my YouTube series on JavaScript. The videos are at https://www.youtube.com/watch?v=UAtJXkGggOU and https://www.youtube.com/watch?v=H2sjsGZyYaw
JavaScript Arithmetic Operators
Arithmetic operators are used to perform arithmetic between variables and/or values.
JavaScript Assignment Operators
Assignment operators are used to assign values to JavaScript variables.
JavaScript String Operators
The + operator, and the += operator can also be used to concatenate (add) strings.
Comparison Operators
Comparison operators are used in logical statements to determine equality or difference between variables or values.
Conditional (Ternary) Operator
The conditional operator assigns a value to a variable based on a condition.
Logical Operators
Logical operators are used to determine the logic between variables or values.
JavaScript Bitwise Operators
Bit operators work on 32 bits numbers. Any numeric operand in the operation is converted into a 32 bit number. The result is converted back to a JavaScript number.
The delete Operator
The delete operator deletes a property from an object:
JavaScript - Chapter 9 - TypeConversion and Regular Expressions WebStackAcademy
Type Conversion:
JavaScript is loosely typed language and most of the time operators automatically convert a value to the right type but there are also cases when we need to explicitly do type conversions.
While JavaScript provides numerous ways to convert data from one type to another but there are two most common data conversions :
Converting Values to String
Converting Values to Numbers
Regular Expressions:
A regular expression is an object that describes a pattern of characters.
The JavaScript RegExp class represents regular expressions, and both String and RegExp define methods that use regular expressions to perform powerful pattern-matching and search-and-replace functions on text.
JavaScript String:
The String object lets you work with a series of characters; it wraps Javascript's string primitive data type with a number of helper methods.
As JavaScript automatically converts between string primitives and String objects, you can call any of the helper methods of the String object on a string primitive.
JavaScript Arrays:
The Array object lets you store multiple values in a single variable. It stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.
Generally speaking, a function is a "subprogram" that can be called by code external (or internal in the case of recursion) to the function. Like the program itself, a function is composed of a sequence of statements called the function body. Values can be passed to a function, and the function will return a value.
In JavaScript, functions are first-class objects, because they can have properties and methods just like any other object. What distinguishes them from other objects is that functions can be called. In brief, they are Function objects.
What is the DOM?
The DOM is a W3C (World Wide Web Consortium) standard.
The DOM defines a standard for accessing documents:
"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."
The W3C DOM standard is separated into 3 different parts:
Core DOM - standard model for all document types
XML DOM - standard model for XML documents
HTML DOM - standard model for HTML documents
The HTML DOM (Document Object Model)
When a web page is loaded, the browser creates a Document Object Model of the page.
The HTML DOM model is constructed as a tree of Objects.
With the HTML DOM, JavaScript can access and change all the elements of an HTML document.
What is JavaScript?
JavaScript is a very powerful client-side scripting language. JavaScript is used mainly for enhancing the interaction of a user with the webpage. In other words, you can make your webpage more lively and interactive, with the help of JavaScript. JavaScript is also being used widely in game development and Mobile application development.
JavaScript String:
The String object lets you work with a series of characters; it wraps Javascript's string primitive data type with a number of helper methods.
As JavaScript automatically converts between string primitives and String objects, you can call any of the helper methods of the String object on a string primitive.
JavaScript Arrays:
The Array object lets you store multiple values in a single variable. It stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type.
Generally speaking, a function is a "subprogram" that can be called by code external (or internal in the case of recursion) to the function. Like the program itself, a function is composed of a sequence of statements called the function body. Values can be passed to a function, and the function will return a value.
In JavaScript, functions are first-class objects, because they can have properties and methods just like any other object. What distinguishes them from other objects is that functions can be called. In brief, they are Function objects.
What is the DOM?
The DOM is a W3C (World Wide Web Consortium) standard.
The DOM defines a standard for accessing documents:
"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."
The W3C DOM standard is separated into 3 different parts:
Core DOM - standard model for all document types
XML DOM - standard model for XML documents
HTML DOM - standard model for HTML documents
The HTML DOM (Document Object Model)
When a web page is loaded, the browser creates a Document Object Model of the page.
The HTML DOM model is constructed as a tree of Objects.
With the HTML DOM, JavaScript can access and change all the elements of an HTML document.
What is JavaScript?
JavaScript is a very powerful client-side scripting language. JavaScript is used mainly for enhancing the interaction of a user with the webpage. In other words, you can make your webpage more lively and interactive, with the help of JavaScript. JavaScript is also being used widely in game development and Mobile application development.
Webstack Academy - Course Demo Webinar and Placement JourneyWebStackAcademy
At WebStack Academy, we understand the importance of providing valuable insights to aspiring professionals like yourself. That's why we host monthly webinars tailored to address the needs of ambitious individuals. Led by our esteemed experts - Mr. Jayakumar (Director, WebStack Academy) and Mr. Mubeen (Technology Head, WebStack Academy), the presentation will offer a firsthand understanding of industry trends, career pathways, and how our Full Stack course can be the catalyst to realizing your career aspirations.
WSA: Scaling Web Service to Handle Millions of Requests per SecondWebStackAcademy
In this presentation of Venkata Ramana Gollamudi, Principal Architect at Flipkart, as our esteemed speaker. With his expertise and experience, he'll guide us through the intricate process of “Scaling web service to handle millions of requests per second”.
Key Takeaways:
Understanding the specific challenges of scaling for Indian users
Strategies to ensure service availability, reduce latency, and maintain reliability
Leveraging tools like ELBs, K8s, message queues, and NoSQL databases effectively
Don't miss this unparalleled opportunity to gain invaluable insights and elevate your expertise in scaling web services to new heights.
We eagerly await your participation in this transformative webinar. Let's embark on the journey to mastering scalability together!
WSA: Course Demo Webinar - Full Stack Developer CourseWebStackAcademy
At WebStack Academy, we understand the importance of providing valuable insights to aspiring professionals like yourself. We host monthly webinars tailored to address the needs of ambitious individuals. Led by our esteemed experts - Mr. Jayakumar (Director, WebStack Academy) and Mr. Mubeen (Technology Head, WebStack Academy), these webinars presentation deck offer a firsthand understanding of industry trends, career pathways, and how our Full Stack course can be the catalyst to realizing your career aspirations.
Career Building in AI - Technologies, Trends and OpportunitiesWebStackAcademy
We from WSA always believe in sharing the right information and enabling you to make decisions for your long term career.
In this regard, Masterclass Webinar on "Career Building in AI - Technologies, Trends and Opportunities” by Renganathan Sekar - Product Manager, Artificial Intelligence - Samsung Research Institute.
Key takeaways from this slide deck:
*Gain a comprehensive overview of AI and its wide range of applications.
*Explore real-world use cases that exemplify the incredible potential of AI.
*Delve into the core technologies driving AI innovation.
*Stay ahead of recent trends in AI, including the intriguing concept of Gen AI.
*Uncover a wealth of opportunities in the AI landscape.
*Learn effective strategies to up skill and advance your career in the AI industry.
WSA Free online Internship for Web Development is an Online real-time experience for Engineering students. It will take you through a journey of skill building and project building experience. You will understand the various product development phases and skills required to work on any Web Application product in Industry.
A guide designed to help you master the art of web development. The roadmap provides a comprehensive step-by-step guide to learn foundational web technologies like HTML, CSS, & JavaScript, advanced frameworks, and concepts required for modern web development. It aims to equip aspiring developers with the necessary resources and tools to excel in the ever-evolving world of web development. 💡
Angular - Chapter 9 - Authentication and AuthorizationWebStackAcademy
Authentication is the process of validating a user on the credentials (username and password)
and provide access to the web application(ex: Email)
Authorization helps you to control access rights by granting or denying specific permissions
to an authenticated user (Ex: User / Manager / Admin).
Http Service will help us fetch external data, post to it, etc. We need to import the http module to make use of the http service. Let us consider an example to understand how to make use of the http service.
AngularFire is the officially supported AngularJS binding for Firebase. ... The focus of this library is to abstract much of the boilerplate involved in creating Angular bindings from Firebase to Angular, and to make it easy to create services that sync to your database.
A directive is a custom HTML element that is used to extend the power of HTML. Angular 2 has the following directives that get called as part of the BrowserModule module.
ngif
ngFor
If you view the app.module.ts file, you will see the following code and the BrowserModule module defined. By defining this module, you will have access to the 2 directives.
Angular - Chapter 4 - Data and Event HandlingWebStackAcademy
In Angular , events such as button click or any other sort of events can also be handled very easily. The events get triggered from the html page and are sent across to Angular JS class for further processing.
Data binding is a core concept in Angular and allows to define communication between a component and the DOM, making it very easy to define interactive applications without worrying about pushing and pulling data. There are four forms of data binding and they differ in the way the data is flowing.
Components are the most basic UI building block of an Angular app. An Angular app contains a tree of Angular components.
Angular components are a subset of directives, always associated with a template. Unlike other directives, only one component can be instantiated per an element in a template.
A component must belong to an NgModule in order for it to be available to another component or application. To make it a member of an NgModule, list it in the declarations field of the NgModule metadata.
TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. TypeScript is pure object oriented with classes, interfaces and statically typed like C# or Java. The popular JavaScript framework Angular 2.0 is written in TypeScript. Mastering TypeScript can help programmers to write object-oriented programs and have them compiled to JavaScript, both on server side and client side.
AngularJS is a structural framework for dynamic web apps. It lets you use HTML as your template language and lets you extend HTML's syntax to express your application's components clearly and succinctly. AngularJS's data binding and dependency injection eliminate much of the code you would otherwise have to write. And it all happens within the browser, making it an ideal partner with any server technology.
Debugging in JavaScript
It is common to have errors while writing codes and the errors can be due to syntax or logical. These errors create a lot of ambiguity in the logic and understanding of both users and programmers. There can also be errors in the code which can remain invisible to the programmer’s eye and can create havoc. To identify these errors we need Debuggers that can go through the entire code or program, identify the errors and also fix them.
-Debugger
The debugger keyword is used in the code to force stop the execution of the code at a breaking point and calls the debugging function. The debugger function is executed if any debugging is needed at all else no action is performed.
Form validation normally used to occur at the server, after the client had entered all the necessary data and then pressed the Submit button. If the data entered by a client was incorrect or was simply missing, the server would have to send all the data back to the client and request that the form be resubmitted with correct information. This was really a lengthy process which used to put a lot of burden on the server.
JavaScript provides a way to validate form's data on the client's computer before sending it to the web server. Form validation generally performs two functions.
Basic Validation − First of all, the form must be checked to make sure all the mandatory fields are filled in. It would require just a loop through each field in the form and check for data.
Data Format Validation − Secondly, the data that is entered must be checked for correct form and value. Your code must include appropriate logic to test correctness of data.
The Browser Object Model (BOM) in JavaScript includes the properties and methods for JavaScript to interact with the web browser.
BOM provides you with window object, for example, to show the width and height of the window. It also includes the window.screen object to show the width and height of the screen.
JavaScript Events:
HTML events are "things" that happen to HTML elements. When JavaScript is used in HTML pages, JavaScript can "react" on these events.
What can JavaScript Do?
Event handlers can be used to handle, and verify, user input, user actions, and browser actions:
Things that should be done every time a page loads
Things that should be done when the page is closed
Action that should be performed when a user clicks a button
Content that should be verified when a user inputs data
JavaScript (JS) is a lightweight interpreted or just-in-time compiled programming language with first-class functions. While it is most well-known as the scripting language for Web pages, many non-browser environments also use it, such as Node.js, Apache CouchDB and Adobe Acrobat. JavaScript is a prototype-based, multi-paradigm, dynamic language, supporting object-oriented, imperative, and declarative (e.g. functional programming) styles.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
4. www.webstackacademy.com ‹#›
JS - Reserved Words
●
Any language has a set of words called vocabulary
●
JavaScript also has a set of keywords with special purpose
●
These special purpose keywords words are used to construct
statements as per language syntax and cannot be used as
JavaScript variables, functions, methods or object names
●
Therefore, also called reserve keywords
●
The limited set of keywords help us to write unlimited statements
5. www.webstackacademy.com ‹#›
Reserved Words
abstract debugger final instanceof protected throws
boolean default finally int public transient
break delete float interface return true
byte do for let short try
case double function long static typeof
catch else goto native super var
char enum if new switch void
class export implements null synchronized volatile
const extend import package this while
continue false in private throw with
*keywords in red color are removed from ECMA script 5/6
7. www.webstackacademy.com ‹#›
JS - Variables
●
Variables are container to store values
●
Name must start with
– A letter (a to z or A to Z)
– Underscore( _ )
– Or dollar( $ ) sign
●
After first letter we can use digits (0 to 9)
– Example: x1, y2, ball25, a2b
8. www.webstackacademy.com ‹#›
JS - Variables
●
JavaScript variables are case sensitive, for example
‘sum’ and ‘Sum’ and ‘SUM’ are different variables
Example :
var x = 6;
var y = 7;
var z = x+y;
9. www.webstackacademy.com ‹#›
JS - Data Types
●
There are two types of Data Types in JavaScript
– Primitive data type
– Non-primitive (reference) data type
Note : JavaScript is weakly typed. Every JavaScript variable has a data type , that type can change dynamically
11. www.webstackacademy.com ‹#›
Primitive data type
(String)
●
String - A series of characters enclosed in quotation
marks either single quotation marks ( ' ) or double
quotation marks ( " )
Example :
var name = “Webstack Academy”;
var name = 'Webstack Academy';
12. www.webstackacademy.com ‹#›
Primitive data type
(Number)
●
All numbers are represented in IEEE 754-1985 double
precision floating point format (64 bit)
●
All integers can be represented in -253 to +253 range
●
Largest floating point magnitude can be ± 1.7976x10308
●
Smallest floating point magnitude can be ± 2.2250x10-308
●
If number exceeds the floating point range, its value will be
infinite
13. www.webstackacademy.com ‹#›
●
Floating point number is a formulaic representation which
approximates a real number
●
The most popular code for representing real numbers is called
the IEEE Floating-Point Standard
Sign Exponent Mantissa
Float (32 bits) Single Precision 1 bit 8 bits 23 bits
Double (64 bits) Double Precision 1 bit 11 bits 52 bits
Primitive data type
(Number)
Float : V = (-1)s * 2(E-127) * 1.F
Double : V = (-1)s * 2(E-1023) * 1.F
14. www.webstackacademy.com ‹#›
Primitive data type
(Number formats)
●
The integers can be represented in decimal,
hexadecimal, octal or binary
Example :
var a = 0x10; // Hexadecimal
var b = 010; // Octal number
var c = 0b10; // Binary
var num1 = 5; // Decimal
var num2 = -4.56; // Floating point
15. www.webstackacademy.com ‹#›
Primitive data type
(Number conversion)
●
Converting from string
Example :
var num1 = 0, num2 = 0;
// converting string to number
num1 = Number("35");
num2 = Number.parseInt(“237”);
16. www.webstackacademy.com ‹#›
Primitive data type
(Number conversion)
●
Converting to string
Example :
var str = “”; // Empty string
var num1 = 125;
// converting number to string
str = num1.toString();
17. www.webstackacademy.com ‹#›
Primitive data type
(Number – special values)
Special Value Cause Comparison
Infinity, -Infinity Number too large or
too small to represent
All infinity values compare equal to
each other
NaN (not-a-
number)
Undefined operation NaN never compare equal to
anything (even itself)
18. www.webstackacademy.com ‹#›
Primitive data type
(Number – special value checking)
Method Description
isNaN(number) To test if number is NaN
isFinite(number) To test if number is finite
20. www.webstackacademy.com ‹#›
Primitive data type
(Null)
Example :
var num = null; // value is null but still type is an object.
●
In JavaScript the data type of null is an object
●
The null means empty value or nothing
24. www.webstackacademy.com ‹#›
Objects
●
An Object is logically a collection of properties
●
Objects represents instance through which we can access
members
●
Object properties are written as name:value pairs separated by
comma
Example :
var student={ Name:“Mac”, City:“Banglore”, State:“Karnataka”};
26. www.webstackacademy.com ‹#›
JS – Simple Statements
●
In JavaScript statements are instructions to be executed
by web browser (JavaScript core)
Example :
<script>
var y = 4, z = 7; // statement
var x = y + z; // statement
document.write("x = " + x);
</script>
27. www.webstackacademy.com ‹#›
JS – Compound Statements
Example :
<script>
...
if (num1 > num2) {
if (num1 > num3) {
document.write("Hello");
}
else {
document.write("World");
}
}
...
</script>
28. www.webstackacademy.com ‹#›
JS – Conditional Construct
Conditional
Constructs
Iteration
Selection
for
do while
while
if and its family
switch case
29. www.webstackacademy.com ‹#›
JS – Statements
(conditional - if)
Syntax :
if (condition) {
statement(s);
}
Example :
<script>
var num = 2;
if (num < 5) {
document.write("num < 5");
}
</script>
31. www.webstackacademy.com ‹#›
JS – Statements
(conditional : if-else)
Example :
<script>
var num = 2;
if (num < 5) {
document.write("num is smaller than 5");
}
else {
document.write("num is greater than 5");
}
</script>
33. www.webstackacademy.com ‹#›
JS – Statements
(conditional : if-else if)
Example :
<script>
var num = 2;
if (num < 5) {
document.write("num is smaller than 5");
}
else if (num > 5) {
document.write("num is greater than 5");
}
else {
document.write("num is equal to 5");
}
</script>
34. www.webstackacademy.com ‹#›
JavaScript - Input
Method Description
prompt() It will asks the visitor to input Some information and
stores the information in a variable
confirm() Displays dialog box with two buttons ok and cancel
35. www.webstackacademy.com ‹#›
Example - confirm()
Example :
<script>
var x = confirm('Do you want to continue?');
if (x == true) {
alert("You have clicked on Ok Button.");
}
else {
alert("You have clicked on Cancel Button.");
}
</script>
36. www.webstackacademy.com ‹#›
Example - prompt()
Example :
<script>
var person = prompt("Please enter your name", "");
if (person != null) {
document.write("Hello " + person +
"! How are you today?");
}
</script>
37. www.webstackacademy.com ‹#›
Exercise
●
Write a JavaScript program to input Name, Address,
Phone Number and city using prompt() and display them
●
Write a JavaScript program to find area and perimeter of
rectangle
●
Write a JavaScript program to find simple interest
– Total Amount = principle * (1 + r * t)
38. www.webstackacademy.com ‹#›
Class Work
●
WAP to find the max of two numbers
●
WAP to print the grade for a given percentage
●
WAP to find the greatest of given 3 numbers
●
WAP to find the middle number (by value) of given 3
numbers
40. www.webstackacademy.com ‹#›
JS – Statements
(switch)
<script>
var num = Number(prompt("Enter the number!", ""));
switch(num) {
case 10 : document.write("You have entered 10");
break;
case 20 : document.write("You have entered 20");
break;
default : document.write("Try again");
}
</script>
41. www.webstackacademy.com ‹#›
Class work
●
Write a simple calculator program
– Ask user to enter two numbers
– Ask user to enter operation (+, -, * or /)
– Perform operation and print result
42. www.webstackacademy.com ‹#›
JS – Statements
(while)
Syntax:
while (condition)
{
statement(s);
}
●
Controls the loop.
●
Evaluated before each
execution of loop body
false
true
cond?
code
43. www.webstackacademy.com ‹#›
JS – Statements
(while)
Example:
<script>
var iter = 0;
while(iter < 5)
{
document.write("Looped " + iter + " times <br>");
iter = iter + 1;
}
</script>
44. www.webstackacademy.com ‹#›
JS – Statements
(do - while)
Syntax:
do {
statement(s);
} while (condition);
●
Controls the loop.
●
Evaluated after each
execution of loop body
false
true
cond?
code
45. www.webstackacademy.com ‹#›
JS – Statements
(do-while)
Example:
<script>
var iter = 0;
do {
document.write("Looped " + iter + " times <br>");
iter = iter + 1;
} while ( iter < 5 );
</script>
46. www.webstackacademy.com ‹#›
JS – Statements
(for loop)
Syntax:
for (init-exp; loop-condition; post-eval-exp) {
statement(s);
}; ●
Controls the loop.
●
Evaluated before each
execution of loop body
false
true
cond?
code
48. www.webstackacademy.com ‹#›
JS – Statements
(for loop)
Example:
<script>
for (var iter = 0; iter < 5; iter = iter + 1) {
document.write("Looped " + iter + " times <br>");
}
</script>
49. www.webstackacademy.com ‹#›
JS – Statements
(for-in loop)
●
“for-in” loop is used to iterate over enumerable
properties of an object
Syntax:
for (variable in object) {
statement(s);
}
50. www.webstackacademy.com ‹#›
JS – Statements
(for-in loop)
Example:
<script>
var person = { firstName:”Rajani”, lastName:”Kanth”,
profession:”Actor” };
for (var x in person) {
document.write(person[x] + “ “);
}
</script>
51. www.webstackacademy.com ‹#›
JS – Statements
(for-in loop)
●
loop only iterates over enumerable properties
●
“for-in” loop iterates over the properties of an object in an
arbitrary order
●
“for-in” should not be used to iterate over an Array where
the index order is important
52. www.webstackacademy.com ‹#›
JS – Statements
(for-of loop)
●
“for-of” loop is used to iterate over iterate-able object
●
“for-of” loop is not part of ECMA script
Syntax:
for (variable of object) {
statement(s);
}
53. www.webstackacademy.com ‹#›
JS – Statements
(for-of loop)
Example:
<script>
var array = [1, 2, 3, 4, 5];
for (var x of array) {
document.write(x + “ “);
}
</script>
54. www.webstackacademy.com ‹#›
Class Work
●
W.A.P to print the power of two series using for loop
– 21, 22, 23, 24, 25 ...
●
W.A.P to print the power of N series using Loops
– N1, N2, N3, N4, N5 ...
●
W.A.P to multiply 2 numbers without multiplication operator
●
W.A.P to check whether a number is palindrome or not
55. www.webstackacademy.com ‹#›
Class Work - Pattern
●
Read total (n) number of pattern chars in a line (number
should be “odd”)
●
Read number (m) of pattern char to be printed in the
middle of line (“odd” number)
●
Print the line with two different pattern chars
●
Example – Let's say two types of pattern chars '$' and
'*' to be printed in a line. Total number of chars to be
printed in a line are 9. Three '*' to be printed in middle of
line.
●
Output ==> $$$* * *$$$
58. www.webstackacademy.com ‹#›
JS – Statements
(break)
●
A break statement shall appear only in “switch body” or “loop
body”
●
“break” is used to exit the loop, the statements appearing after
break in the loop will be skipped
●
“break” without label exits/‘jumps out of’ containing loop
●
“break” with label reference jumps out of any block
60. www.webstackacademy.com ‹#›
JS – Statements
(break)
<script>
for (var iter = 0; iter < 10; iter = iter + 1) {
if (iter == 5) {
break;
}
document.write("<br>iter = " + iter);
}
</script>
61. www.webstackacademy.com ‹#›
JS – Statements
(break with label)
Syntax:
outer_loop:
for (condition) {
inner_loop:
for(condition) {
conditional statement
break outer_loop; // jump out of outer_loop
}
}
62. www.webstackacademy.com ‹#›
JS – Statements
(continue)
●
A continue statement causes a jump to the loop-continuation
portion, that is, to the end of the loop body
●
The execution of code appearing after the continue will be
skipped
●
Can be used in any type of multi iteration loop
64. www.webstackacademy.com ‹#›
JS – Statements
(continue)
<script>
for (var iter = 0; iter < 10; iter = iter + 1) {
if (iter == 5) {
continue;
}
document.write("<br>iter = " + iter);
}
</script>
65. www.webstackacademy.com ‹#›
JS – Statements
(continue with label)
Syntax:
outer_loop:
for (condition) {
inner_loop:
for(condition) {
conditional statement
continue outer_loop; // continue from outer_loop
}
}
66. www.webstackacademy.com ‹#›
JS – Statements
(goto)
●
This keyword has been removed from ECMA script 5/6
●
“goto” keyword is is not recommended to use
●
Use break with label if necessary