Anna CS 110 - JavaScript Tutorial for Beginners
School name Anna University
Course Cs 110-
Pages 2

Unformatted text preview:

JavaScript Tutorial for Beginners Learn JavaScript in 1 Hour In this 3 minute introduction I m going to answer four frequently asked questions about JavaScript What is JavaScript what can you do with it where does JavaScript code to run and what is the difference between JavaScript and ECMAScript The average salary of a JavaScript developer in the United States is 72 000 a year Every browser has a JavaScript engine and we can easily write JavaScript code here without any additional tools of course this is not how we build real world applications but this is just for a quick demo In order to write javascript code you need a code editor there are various code editors out there including Visual Studio code or yes code sublime text atom The live server is a lightweight web server that we re going to use to serve our web application so install this then you will have to restart Visual Studio code when you re done go to the Explorer tab right click index HTML and select open with a live server This will open up Chrome or your default browser and point it to this address that s where the web application is served from now JavaScript is a statement a statement is a piece of code that expresses an action to be carried out in this case we want to log a message on the console All statements in JavaScript should be terminated by a semicolon In JavaScript we can add some description to our code and this description is ignored by the JavaScript engine In this lecture I m assuming that you have installed node on your machine if not head over to node js org and download the latest version of node combine these files into a bundle and serve that bundle to the client Save the changes back in the browser you can still see the hello world message and that confirms that our code is still working A variable is one of the most fundamental concepts in JavaScript and any other programming language in programming We use a variable to store data temporarily in a computer s memory We store our data somewhere and give that memory location and name and with this name we can read the data at the given location in the future The best practice is to use the lead keyword to declare a variable The modern best practice is to declare each variable on a single line so we terminate this first declaration with a semicolon and declare the second variable on a new line that s the modern best practice next we re going to look at constants alright now let s declare a variable called interest rate so let the interest rate and we set this to 0 3 now this is the initial value The best practice is to use a constant so the value of a variable as the name implies can change but a constant can not change so here if we change let to Const now interest rate will be a constant In situations where we want to have some logic for example if the order is approved then it needs to be shipped JavaScript is a dynamic language so unlike other programming languages the type of these variables will be determined at runtime based on the values that we assigned to them In JavaScript unlike other languages we don t have two kinds of numbers we don t have floating point numbers and integers In es6 we have another primitive that is a symbol and you re going to learn about that later in the course An object in JavaScript and other programming languages is like an object in real life think of a person who has a name age address and so on these are the properties of a human An object is a type but is also a value in this example because we have set first name to undefined as a value its type is also undefined In this lecture we re going to explore objects and you will learn about arrays and functions In between them we have one or more key value pairs and these are the properties of the personal object now there are two ways to work with these properties The other way to access property is using bracket notation so bracket notation dot notation is a bit more concise it s shorter so that should be your default choice JavaScript is a dynamic language so the type of variables can change at runtime the same principle applies to our arrays Each element in an array has an index that determines the position of that element in the array The length of an array as well as the size of the array are dynamic they can change


View Full Document

Anna CS 110 - JavaScript Tutorial for Beginners

Course: Cs 110-
Pages: 2
Download JavaScript Tutorial for Beginners
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view JavaScript Tutorial for Beginners and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view JavaScript Tutorial for Beginners 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?