No description
AI Reading Assistant
Summary and highlights from this book's index; jump to passages in the text
Tags
Support Statistics
¥.00 ·
0times
Text Preview (First 20 pages)
Registered users can read the full content for free
Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.
Page
1
(This page has no text content)
Page
2
(This page has no text content)
Page
3
© Copyright 2021 - All rights reserved. The contents of this book may not be reproduced, duplicated or transmitted without direct written permission from the author. Under no circumstances will any legal responsibility or blame be held against the publisher for any reparation, damages, or monetary loss due to the information herein, either directly or indirectly. Legal Notice: This book is copyright protected. This is only for personal use. You cannot amend, distribute, sell, use, quote or paraphrase any part or the content within this book without the consent of the author. Disclaimer Notice: Please note the information contained within this document is for educational and entertainment purposes only. Every attempt has been made to provide accurate, up to date and reliable complete information. No warranties of any kind are expressed or implied. Readers acknowledge that the author is not engaging in the rendering of legal, financial, medical or professional advice. The content of this book has been derived from various sources. Please consult a licensed professional before attempting any techniques outlined in this book. By reading this document, the reader agrees that under no circumstances is the author responsible for any losses, direct or indirect, which are incurred as a result of the use of information contained within this document, including, but not limited to, —errors, omissions, or inaccuracies.
Page
4
Table of Contents JAVASCRIPT JavaScript Basics for Beginners Introduction Chapter One: An Introduction to JavaScript The Developer of JavaScript The Use Cases of JavaScript The <script> Tag Display Values Numbers Arithmetic Strings JavaScript Arrays Chapter Two: JavaScript Variables JavaScript Identifiers Datatypes Declaration of Variables The Undefined Variables Re-Declaration Arithmetic JavaScript String Concatenation JavaScript Let Keyword Chapter Three: JavaScript Constants Block Scope Primitive Values JavaScript Constants
Page
5
Chapter Four: Prompts and Conditionals The JavaScript if Statement The else Statement The else if Statement JavaScript Switch Statement Chapter Five: JavaScript Strings and Arrays The lastIndexOf() Method What If the Index Is Not Found? The search() Method JavaScript Arrays JavaScript Array concat() Array Sorting Reverse Gear Sorting Numeric Compare Function Random Sorting Array Values Object Array Sorting JavaScript Iteration Chapter Six: JavaScript Loops The for/in Loop The forEach() Loop The for/of Loop Eternal Loops JavaScript while Loops The do/while Loop JavaScript Break and Continue Statements Chapter Seven: JavaScript Functions The Invocation of Function The () Operator Functions as Variables
Page
6
Local Variables JavaScript Expressions The constructor() Self-Invoking Functions or Objects The toString() Method Arrow Functions Parameters & Arguments Invocation Global Objects Reusing Methods Chapter Eight: JavaScript Objects The new Keyword Object Properties The Deletion Dates JavaScript Classes Passing Parameters Class Inheritance Conclusion References JAVASCRIPT JavaScript Front End Programming Introduction React Advantages React Limitations Chapter 1: ReactJS - Environment Setup Local Environment Setup With Webpack and Babel
Page
7
The create-react-app Command Chapter 2: Introducing React JSX Why Use JSX? How to Embed Expressions in JSX JSX is an Expression Specifying Attributes with JSX How to Specify Children with JSX Preventing Injection Attacks with JSX JSX Represents Objects Chapter 3: All About Components The Component Lifecycle Commonly Used Lifecycle Methods Lifecycle Methods Rarely Used Error Boundaries Class Properties Instance Properties Chapter 4: State and Lifecycle Converting Functions to Classes Add Local State to a Class Add Lifecycle Method to the Class Correctly Using State Data Flows Down Chapter 5: ReactJS Props and PropTypes Understanding Props What Are React PropTypes? Chapter 6: ReactJS Forms Step One – Use JSX to Create a Basic Form Step Two – Using Uncontrolled Components to Collect Form Data Step Three – Using Controlled Components to Update Form Data Step Four – Update Form Properties Dynamically
Page
8
Chapter 7: ReactJS Events Creating Events Listening To Component Events Adding Event Listeners Handling Events Passing an Argument to an Event Handler Chapter 8: ReactJS Refs Creating Refs Using React Refs Integration with DOM-Based Libraries Rule of Thumb for Using Refs Forwarding Refs Chapter 9: ReactJS Lists and Keys Rendering Lists in Components All About Keys Chapter 10: ReactJS Router Routers Routes Switch Component Link Component Nested Routing Protected Routes Custom Routes Chapter 11: ReactJS – Introduction to Flux Introducing Flux Mixin Example Syncing with Web APIs Chapter 12: ReactJS Animations Introducing React Animation Chapter 13: ReactJS Higher Order Components
Page
9
Higher-Order Functions in JavaScript What is a Higher-Order Component? Higher Order Component Structure Building a Higher Order Component - Example Chapter 14: ReactJS Best Practices Chapter 15: Let’s Create a React App Step One: Setting Up a Boilerplate App Step Two: The React App Structure Step Three: Starting the Development Server Conclusion References JAVASCRIPT JavaScript Back End Programming Introduction Chapter One: Setting Up Your Node.js Environment Windows Mac and Linux IDE Installation IDE – Visual Studio Code Hello World Chapter Two: Node.js - REPL Terminal Step One — Start and Stop the REPL Step Two — Execute Code in the REPL Step Three — Mastering REPL Shortcuts Step Four — The REPL Commands Chapter Three: Node.js - Package Manager (NPM) Downloads and Installing Dependencies Versioning
Page
10
Running Tasks Where Does npm Install the Packages? Using or Executing Packages Installed With npm Chapter Four: Node.js Callbacks and Promises Chapter Five: Asynchronous JavaScript Programming Synchronous JavaScript Asynchronous JavaScript Async Callbacks Promises Asynchronous Code Nature Chapter Six: Node.js Event Loops and Event Emitters Phase Overview setImmediate() vs setTimeout() process.nextTick() process.nextTick() vs setImmediate() Chapter Seven: Node.js Buffers What Are Buffers? More Fun With Buffers Chapter Eight: Node.js Streams What Are Streams? Async Iterator How to Create a Writable Stream pipeline() The Stream Module Chapter Nine: Node.js File System What is the Synchronous and Asynchronous Approach? Important fs.module Methods Chapter Ten: Node.js Global Objects Global Object Global Modules and Functions
Page
11
Global Objects Chapter Eleven: Node.JS Utility Modules OS Module OS Module Methods Path Module Net Module Class - net.Server Class - net.Socket DNS Module Domain Module Chapter Twelve: Node.js Web Module Web Application Architecture Using Node to Create a Web Server Make a Request to Node.js Server Create a Web Client Using Node Chapter Thirteen: Node.js Express Framework What is Express.js? Installing and Using Express What are Routes? Building a Web Server with Express.js Chapter Fourteen: Node.js RESTful API HTTP Methods RESTful Web Services How to Create RESTful for a Library List Users Add User Show Detail Delete User Chapter Fifteen: Node.js Scalable Applications Strategies of Scalability
Page
12
The Cluster Module Load-Balancing an HTTP Server Broadcasting Messages to All Workers Increasing Availability of the Server Zero-Downtime Restarts Shared State and Sticky Load Balancing Chapter Sixteen: Node.js Packaging Packaging Your Node.js App Package Using the Command-Line Package Using the Code Chapter Seventeen: MongoDB + Mongoose with Node.js – Best Practices for Back End Developers Why You Need Mongoose Performing Mongoose Operations Performing CRUD Operations Conclusion References
Page
13
JAVASCRIPT JAVASCRIPT BASICS FOR BEGINNERS Andy Vickler
Page
14
Introduction This book contains proven steps and strategies on how to code in JavaScript. I have included in the book step-by-step programming techniques in JavaScript so that you can learn them properly. JavaScript is a scripted language. You will see a lot of script embedded in HTML tags. As JavaScript cannot work alone, I deemed it fit to embed it in HTML so that when you want to run it, it works well in web browsers. If you want to practice what you have learned, you can open up a code editor, copy the code, and paste it in to check out the results. Also, you can simply load up the page to the web browser to see the results directly on the web page. Embedded scripts are in ready-to-work form. The best method to learn the scripts by heart and then edit them to customize them so that you can learn faster and in a fun way. Whether you are making websites or are a student who aspires to become a web developer, or are planning to build a website for your own business, this book is the best literature you may come across on the market. Once you have gone through the first couple of chapters, you will be in the right mindset to move on and learn the complex topics. The best method is to go slow at first and pace yourself as the concepts become clearer. Chapter One An Introduction to JavaScript JavaScript is an interpreted language. The definition of the language is broader than the word interpreted. You can define it as a procedural language that is weakly typed, based on prototypes, and is dynamic and imperative. JavaScript is developed and implemented in the form of a client-side
Page
15
programming language. It is a part of the web browser and is seen as something that can facilitate developers for the implementation of dynamic features and creation and integration of user interface on the web pages. You may find some implementation of JavaScript on the server-side as well. However, the popularity of the JavaScript programming language is largely based on its applications on the client-side. You may see applications of JavaScript outside of web applications as well. For example, you may find them being used as a way to add some interactivity to the desktop widgets and to documents in PDF format. JavaScript was initially designed in the same mold as the C language was designed, but it also takes some Java programming language names. You should not mistake Java for JavaScript because the two are inherently different. They have different purposes and semantics as well. The Developer of JavaScript Brendan Each developed JavaScript initially with the name Mocha. The name was changed later on to LiveScript. Late on, it was changed again to JavaScript. The name confused some people, and it gave the impression that the new language, namely JavaScript, was an offshoot of Java. People thought that the new programing language was part of Netscape's marketing strategy to gain the much-needed prestige in the world of new programming languages. The next year, Microsoft introduced a similar client-side language integrated into their famous Internet Explorer 3.0 browser. It named the language JScript to get away with brand problems. The term as it sounds and looks was perceived as so much similar to JavaScript; however, where it differed was that it could not be made 100% compatible with the specifications of ECMA. In 1997, a proposal popped up to submit JavaScript to ECMA standards, and in June 1997, ECMA standards adopted it with the nametag ECMAScript. The programming language also won the ISO standard recommendation. JavaScript amassed high-rated popularity because of the way it adapted to the internet. That is the reason it became one of the most used programming languages across the planet.
Page
16
The Use Cases of JavaScript JavaScript is at work at the client-side of most of the webpages around the world. When you open a webpage, and it had changed from when you previously opened it, well, those changes could have been made using JavaScript. Let me tell you something interesting. Open a web page on your computer screen. Right-click on the web page and then click on View Source. You will see the word JavaScript inside the code of the page. Do not confuse HTML with JavaScript because you may find the two in the code of the page. HTML is a markup language that allows developers to format the content and create a dynamic web page. You can turn the text into bold, create the boxes and tables of your choice, and add buttons and bullets to the page. However, JavaScript lets you alter the text, add pop-up messages, and validate the text you have entered through HTML coding. HTML and JavaScript walk side by side. Where JavaScript moves ahead of HTML is the way it makes the page dynamic and interactive. It will allow your users to click on certain elements and open new pages from the existing page. You should learn JavaScript because it is very easy to implement. All you need is to put the code in an HTML document and then instruct the browser to run it. JavaScript works on many computers and operating systems, even when the systems are offline. With JavaScript's help, you can create responsive interfaces that refine user experience and offers extremely dynamic functionality. JavaScript allows users to load up content in the form of a document whenever the user needs it, and that too without putting the web page into a reload. We call the process Ajax. JavaScript allows you to run a test for existing possibilities in the browser and then react accordingly. The process is known as defensive Scripting. JavaScript will fix any problems that emerge on your web pages. It will cover up the holes that exist in the browser support. When we compare all that JavaScript can do for us with other programming languages for the web, we realize that it can do so much more. JavaScript is highly demanded and loved because it allows you to build complex applications without any hassle. You can build complex applications with Flash as well, but JavaScript is the best way to go because it is a web
Page
17
standard. When it comes to the uses of JavaScript, the uses keep on changing. At first, JavaScript's interaction with a website was constricted to forming interaction and giving users feedback. However, it evolved with time, and now the uses are much more than how it started. The use cases of JavaScript are changing with the change of times. Users need to change the tried, tested, and boring web interface of clicking on links, filling out information on a web page, and sending off a bunch of forms. They look at making the same processes more modern and user-friendly. JavaScript has enabled users to create a sign-up form that has the capacity to check if a username is already taken or is available. This prevents users from enduring page reload that can somewhat be highly frustrating. A search box shows you the more relevant and suggested results when you type something. It shows something that is based on your entries. The pattern is known as autocomplete - without JavaScript, that would not have been possible. The information that needs to change after set times without any input from the user is possible with the help of JavaScript. JavaScript may attempt to fix layout issues. By using JavaScript, you may find the exact area and position of any element on your web page. You can calculate the dimensions of the window of your browser. By collecting and using this information, you may help prevent the overlap of elements and other related issues. Let us suppose you have a menu for different levels. You can prevent the overlap of the menu items and scroll-bars by checking out the space for the sub-menu. Perhaps the best way by which JavaScript can help you is to enhance the interface that HTML gives you. Code is labeled as the text that forms programs. In many chapters of the books, you will find a lot of code. Reading and writing code, I must say, is an integral part of the process to learn and write programs. Metaprogramming is considered a powerful technique that can enable you to write a set of programs. The advent of ES6 has further eased off the utilization of metaprogramming in the world of JavaScript programming. You can use proxies and other similar features. The proxies of ES6 tend to facilitate the redefinition of different operations in objects.
Page
18
The <script> Tag Let us talk about the symbol that is the most used tag in the book. All the JavaScript code is enclosed inside the <script> tags. <!DOCTYPE html> <html> <body> <p>JavaScript rests in the Body</p> <p id="demo12"></p> <script> document.getElementById("demo12").innerHTML = "This is your First JavaScript"; </script> </body> </html> JavaScript Rests in the Body This is your First JavaScript The older type of JavaScript was written differently. It had the following format such as <script type = “text/javascript”>. There are functions in JavaScript that you can use to execute blocks of code. You may call a function when some kind of event occurs. An event can be defined as a click button. You can place any kind of script in an HTML document. You can place the scripts either in the <head> or in the <body> or in both of them. The example of using a script in the head is as under: <!DOCTYPE html> <html> <head> <script> function FunctionUN() { document.getElementById("demo34").innerHTML = "I have changed the Paragraph."; } </script> </head> <body> <p>You have seen the JavaScript in the Head</p> <p id="demo">This is a Paragraph.</p> <button type="button" onclick="FunctionUN()">Click Me</button> </body> </html> You have seen the JavaScript in the Head This is a Paragraph. Click Me
Page
19
When you click the button on the web browser, you will trigger an invocation of the function. You also can put the script inside the <body> of the HTML page. You will invoke this function when you click the button. <!DOCTYPE html> <html> <body> <p>This is A Web Page</p> <p id="demo1">This is a Paragraph</p> <button type="button" onclick="FunctionZ()">Click Me</button> <script> function FunctionZ() { document.getElementById("demo1").innerHTML = "I have changed the Paragraph."; } </script> </body> </html> This is A Web Page I have changed the Paragraph. Click Me Display There are different methods to display JavaScript in web browsers. Programmers use different techniques for display purposes. The first method that I have used in the book is the document.getElementById(id) method. In the phrase, id refers to the element that defines the HTML document. The word innerHTML defines the content of HTML. <!DOCTYPE html> <html> <body> <p>This is going to be my First Web Page</p> <p>This will be the First Paragraph.</p> <p id="demo1234"></p> <script> document.getElementById("demo1234").innerHTML = 4567 + 36; </script> </body> </html> This is going to be my First Web Page This will be the First Paragraph. 4603 The second method that you can use is the document.write() method. This
Page
20
also is a simple one. However, I have not created any script in the book by using this method except for this example to show you how it works: <!DOCTYPE html> <html> <body> <p>This is going to be my First Web Page</p> <p>This will be the First Paragraph.</p> <p id="demo1234"></p> <script> document.write (4567 + 36); </script> </body> </html> This is going to be my First Web Page This will be the First Paragraph. 4603 If you use this method after loading the HTML page, you will lose all data because it will be deleted. Therefore, you should beware of the consequences if you make this mistake. Also, you can create a button with this method and test the HTML page. See the following example. <!DOCTYPE html> <html> <body> <p>This is going to be my First Web Page</p> <p>This will be the First Paragraph.</p> <button type="button" onclick="document.write(335 + 6)">Click me</button> </body> </html> This is going to be my First Web Page This will be the First Paragraph. Click me Another method is the window alert method. <!DOCTYPE html> <html> <body> <p>This is going to be my First Web Page</p> <p>This will be the First Paragraph.</p> <p id="demo1234"></p> <script> window.alert (4567 + 36); </script>
Loading comments...
Reply to Comment
Edit Comment